I have the following code. Note the wild card is what I actually want. (please forgive the bad code before final refactor).
string findRegex = "{f:.*}";
Regex regex = new Regex(findRegex);
foreach (Match match in regex.Matches(blockOfText))
{
string findCapture = match.Captures[0].Value;
string between = findCapture.Replace("{f:", "").Replace("}", "");
}
What I dont like about the code is trying to get what is in between what I found, the double replace statements. Is there a better way?
Additional: Here is a sample string
Dear {f:FirstName} {f:LastName},
You can use parens to group part of your match and extract it later:
If you want exactly two matches (e.g. for your first-name last-name example), make two groups: