I have the following code:
string pattern =
@"(\{)|(})|(\()|(\))|(\[)|(])|(\^)|(\*)|(/)|(-)|(\+)|(%)";
Regex regex = new Regex(pattern);
string input = "QTY * ESTIMATED COST + 2";
string[] tokens = regex.Split(input);
for (int i = 0; i != tokens.Length; i++)
{
Console.WriteLine("Token {0} = {1}", i, tokens[i].Trim());
}
Console.ReadLine();
According to the documentation on the Split function, the returned
string array will include the captures if I use capturing groups. IOW, I
should get an array containing 5 elements. Instead I'm only getting
three (QTY, ESTIMATED COST and 2). What am I doing wrong?
--
There are 10 kinds of people. Those who understand binary and those who
don't.
http://code.acadx.com
(Pull the pin to reply)