我有以下正则表达式,我匹配了几行。
这是一个例子:
field1 xyz
field2 yiuyi
field3 12.34.12
这是我的正则表达式:
static string partPattern = @"^(?<Key>\w*)\s+(?<Value>\w*)$";
这是我使用的代码:
Match m = Regex.Match(line, partPattern);
if (m.Groups["Key"].Length > 0 && m.Groups["Value"].Length > 0)
{
//add to Dictionary
}
它在所有情况下都可以正常工作,除非有日期。我只是想让它获取值,而不管空白、引号或其他任何内容。