Regex Again

Jay1b

Well-known member
Joined
Aug 3, 2003
Messages
640
Location
Kent, Uk.
I have tried getting to grips with this before but i cant seem to get it working - actually i cant seem to find a decent example of it even.

I have a string consisting of approx:
123,456,789,abc,def

I would like to take this string and split it up into the array below:

testarray(1) = 123
testarray(2) = 456
testarray(3) = 789
testarray(4) = abc
testarray(5) = def

Could someone please give me an example of how the code would work for this please? I believe regex (within a loop) would be the best way to do this. Although i know it can also be done with splitstring. - something else i am not too sure about :(

Thanks.
 
There is a regex.split function you can use.

Something like:


dim r as new regex(",")
dim testarray as string() = r.split("123,456,789,abc,def")

Hope this helps.
 
Back
Top