EDN Admin
Well-known member
I am new to C#. I have the following test code and it does not work as expected on the regex. The regex works in ruby and Regex Coach so I know it is good. It returns 5 values. In c# it returns 1 match which is the original
string. What is my mistake?
string[] rxVals = new string[10];
string regex = @"(w+),s+(w+)s+(d+),s+(d+),s+(d+)";<br/>
string text = "Wednesday, February 15, 2012, 11:00 AM CST";<br/>
Regex rx = new Regex(regex, RegexOptions.IgnoreCase);<br/>
MatchCollection matches = rx.Matches(text);<br/>
int vCnt = 1;<br/>
foreach (Match match in matches)<br/>
{<br/>
GroupCollection groups = match.Groups;<br/>
rxVals[vCnt] = groups[0].Value;<br/>
vCnt++;<br/>
}
View the full article
string. What is my mistake?
string[] rxVals = new string[10];
string regex = @"(w+),s+(w+)s+(d+),s+(d+),s+(d+)";<br/>
string text = "Wednesday, February 15, 2012, 11:00 AM CST";<br/>
Regex rx = new Regex(regex, RegexOptions.IgnoreCase);<br/>
MatchCollection matches = rx.Matches(text);<br/>
int vCnt = 1;<br/>
foreach (Match match in matches)<br/>
{<br/>
GroupCollection groups = match.Groups;<br/>
rxVals[vCnt] = groups[0].Value;<br/>
vCnt++;<br/>
}
View the full article