Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created June 6, 2024 13:32
Show Gist options
  • Save bjoerntx/0e833871c3f23c67e301ef35f77bf1b8 to your computer and use it in GitHub Desktop.
Save bjoerntx/0e833871c3f23c67e301ef35f77bf1b8 to your computer and use it in GitHub Desktop.
private static List<FieldInfo> FindMergeFields(string input)
{
const string pattern = @"\{\{(?!#|/)(.*?)\}\}";
var matches = new List<FieldInfo>();
foreach (Match match in Regex.Matches(input, pattern))
{
matches.Add(new FieldInfo
{
StartIndex = match.Index,
EndIndex = match.Index + match.Length,
FieldName = Regex.Replace(match.Groups[1].Value, @"\s+", "")
});
}
return matches;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment