Skip to content

Instantly share code, notes, and snippets.

@akimboyko
Created December 13, 2012 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akimboyko/4275479 to your computer and use it in GitHub Desktop.
Save akimboyko/4275479 to your computer and use it in GitHub Desktop.
Regex with {}
void Main()
{
var input = @"{TEST} is {TEST}";
ObtainTokens(input).Dump();
}
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