martin_d_bell Posted January 24, 2005 Posted January 24, 2005 Hi Everyone, I have a string in the form of Blah1, Blah2, Blah3, Blah4, Blah5 I need to strip the Blah's and store them as separate string variables such as strVar1 = Blah1 strVar2 = Blah2 strVar3 = Blah3 etc etc The string will be of different lengths and could contain 3 Blah's or 8 Blahs so the string length is never constant. I get the feeling that a regular expression is the solution but haven't got a clue how to write one of these to do the job. If anyone could help it would be very much appreciated. Thanks in advance. Martin Quote
Administrators PlausiblyDamp Posted January 24, 2005 Administrators Posted January 24, 2005 You could use the simple string.Split method dim s as string = "Blah1, Blah2, Blah3, Blah4, Blah5" 'or whatever the string is dim ans() as string = s.split(",") or if you really require regular expressions then something like Dim r as new RegEx("(,)") Dim s as String = "Blah1, Blah2, Blah3, Blah4, Blah5" dim ans() as String = r.Split(s) should do it. may not be exact as I don't have VS on this PC. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
martin_d_bell Posted February 2, 2005 Author Posted February 2, 2005 Thanks Thanks alot for your help. I used the spit function in the end. Sometimes the answer is right under your nose but I manage to spend 2 hours over complicating things!! Oh well, thank you. ;) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.