I have the following regular expression with which I match a few lines.
Here is an example:
field1 xyz
field2 yiuyi
field3 12.34.12
This is my regex:
static string partPattern = @"^(?<Key>\w*)\s+(?<Value>\w*)$";
This is the code I use:
Match m = Regex.Match(line, partPattern);
if (m.Groups["Key"].Length > 0 && m.Groups["Value"].Length > 0)
{
//add to Dictionary
}
It works fine in all cases except when there is a date. I just wanted to make it so that it fetches the values regardless of blank, quotes, or anything else.
You are using word characters (
\w), which include[a-zA-Z0-9_], but you probably want to match any character, at least for theValue.