Reputation: 93
I have a simple question: my long text is full of: text:value;text:value;...
.
My question is how do you get all values between :
and ;
My half-correct(?) pattern is:
text:(.*);.text:
Could someone show me a better way?
Upvotes: 3
Views: 529
Reputation: 7804
Pattern: \w+:(?<value>\w+);
Regex pattern = new Regex(@"\w+:(?<value>\w+);");
foreach (Match match in pattern.Matches("text:bar;text:foo;"))
Console.WriteLine(match.Groups["value"].Value);
Prints:
bar
foo
Upvotes: 2
Reputation: 1886
This is the regex you are searching:
text:([^;]*);
Where [^;]
matches everything but the semicolon.
Upvotes: 4