Reputation: 57
I have a large string that may have some items I want to retrieve out of it.
An example string could be
"The quick |Get Me|(header1) brown fox |Get Me|(info package) jumps over ..."
I would like a regex to extract what is in between the brackets, not including the brackets and the brackets will always follow "|Get Me|"
Upvotes: 1
Views: 73
Reputation: 499002
A pattern that will match:
\|Get Me\|\(([^)]+)\)
Usage:
var matches = Regex.Matches(myString, @"\|Get Me\|\(([^)]+)\)");
foreach(Match match in matches)
{
var val = match.Groups[1].Value;
}
Upvotes: 4