//regex expression to take out any ctrl + somekey values
private System.Text.RegularExpressions.Regex Regx = new
System.Text.RegularExpressions.Regex(@"[\cA-\cZ]");
private char[] _split = { ' ' };
string mystring = " I am new to c# ";
mystring = mystring.Replace(" "," ");
mystring = mystring.Replace(" "," ").Trim();
string[] line = null;
//regx implementation
line = Regx.Replace(mystring,"").ToString().Split(_split) ;
output would be:
line [0] = "I"
line [1] = "am"
line [2] = "new"
line [3] = "to"
line [4] = "c#"
Cheers!
Rob
"dchan1" wrote:
String line = " I am new to c# ";
How to use Regex to split the string so that It would return a String array
with:
token[0] = "I"
token[1] = "am"
token[2] = "new"
token[3] = "to"
token[4] = "c#"
Please help.
thanks