开发者

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

I am trying to add to a page that someone else has written. I need to take a string that is formated with either 3 or 4 alpha characters followed by a series of numbers. I need to remove these alpha characters so that only a string of numbers is left.

Example: What I'm string with is TrailerNumber = "CIN0012345" and I need the result to be TrailerNumberTrimed = 开发者_如何学Python"0012345"

This is a web application written in an ASP (to be clear not ASPX) and VB page. This code will have to run on the server because it is being used as a search value in a database.


Not tested, but should work (assuming start of string is always 3/4 alpha followed by all numbers):

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜