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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I split a string with unusual characters? 1

Status
Not open for further replies.

Sniipe

Programmer
Oct 9, 2006
115
0
0
IE
I have a string like this:
"'IRE','ENG','SCO','WAL'"

And I want to put it into an array like this:

string[] countries = codesList.Split("','");

Well thats the idea anyway but I can't get it to split, nor can I just replace the char ' . Any ideas?
 
String codesList = "'IRE','ENG','SCO','WAL'";
String[] countries = codesList.Replace( "'", null).Split("','".ToCharArray());
 
sweet as a nut! Thanks B00gyeMan. Your a sound man as they say over here (thats a good thing) :D
 
Just as an alternative (though B00gyMan is right as well) is to use the regular expression split, which actually takes a string instead of a character array.

Enjoy!
-Kevin

- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top