get numbers from string

A

Alexander Widera

hi,

i have a string "testing123testing".... I want out of this string only the
numbers (123) ... how can i make this?
perhaps there are some more difficulties ... if the string is
"testing123test456anothertest" ... i want both numbers ... 123 and 456 ...

thanks

Alex
 
T

tom.pesterDeLeTeTHISSS

Thats a job for regular expressions. Dont be scared of them. If you are intrested
i recommend the book http://www.oreilly.com/catalog/regex/ by Friedl

The following code will help you on the way

Dim re As New Regex("\d+")

Dim matches As MatchCollection = re.Matches("test887rere95zzz")
Dim match As Match

For Each match In matches
Response.Write("-" & match.Groups(0).ToString)
Next



Cheers,
Tom Pester
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top