Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to seperate Alphabets & Numbers from a string?

Status
Not open for further replies.

Mahey

Programmer
Dec 24, 2008
52
SA
Hi,

I like to know to split a string value from a mixed value
suppose

Dim MyStr As String = "Check121"
Dim Regex As String = Space(15)
For i1 As Integer = 0 To MyStr.Length - 1
If Not IsNumeric(MyStr.Substring(i1, 1)) Then
Regex = Trim(Regex) + MyStr.Substring(i1, 1)
End If
Next

Now the result will be "Check"
Is there any short ideas?

Thanks
 
If yo know that all string will start with non-muneric and end with numeric you coud use

Dim result as string
Dim myStr as string = "Check121"
Dim x as integer = 0

Do while x<len(myStr)
x+=1
if IsNumeric(myStr.Substring(x,1)) then exit do
loop

result = myStr.Substring(1,x-1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top