i wish to match a multiple field value delimited by a colon in a single line, but each field and value text contains space e.g.
field1 : value1a value1b
answer
match1: Group1=field1, Group2=value1a value1b
or
field1 : value1a value1b field2 : value2a value2b
answer
match1: Group1=field1, Group2=value1a value1b
match2: Group1=field2, Group2=value2a value2b
the best i can do right now is (\w+)\s*:\s*(\w+)
Regex regex = new Regex(@"(\w+)\s*:\s*(\w+)");
Match m = regex.Match("field1 : value1a value1b field2 : value2a value2b");
while (m.Success)
{
string f = m.Groups[1].Value.Trim();
string v = m.Group2[2].Value.Trim();
}
i guess look ahead may help, but i don't know how to make it thank you