关于ASP Classic:删除字符串中的字符,直到在ASP和VB中找到数字为止

Remove chars in a string until numeric is found in ASP and VB

我正在尝试添加到其他人撰写的页面上。我需要一个字符串,该字符串的格式为3个或4个字母字符,后跟一系列数字。我需要删除这些字母字符,以便只剩下一串数字。

示例:
我的字符串是TrailerNumber = " CIN0012345 "
我需要结果为TrailerNumberTrimed = " 0012345 "

这是一个用ASP(显然不是ASPX)和VB页面编写的Web应用程序。此代码必须在服务器上运行,因为它被用作数据库中的搜索值。


未经测试,但可以正常工作(假设字符串的开头始终为3/4 alpha,后跟所有数字):

1
2
3
4
5
6
7
8
9
10
11
Dim TrailerNumberTrimed

If IsNumeric(Right(TrailerNumber, Len(TrailerNumber) - 4)) Then
    TrailerNumberTrimed = Right(TrailerNumber, Len(TrailerNumber) - 4)
End If

If IsNumeric(Right(TrailerNumber, Len(TrailerNumber) - 3)) Then
    TrailerNumberTrimed = Right(TrailerNumber, Len(TrailerNumber) - 4)
End If

' At this point, you should have the correct trimmed trailer number