Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Regex with {}
void Main()
var input = @"{TEST} is {TEST}";
public static IEnumerable<string> ObtainTokens(/*this*/ string originalString)
Regex expression = new Regex(@"{(\w*)}");
foreach (Match element in expression.Matches(originalString))
//Exclude the brackets from the returned valued
yield return element.Groups[1].Value;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment