Created
December 13, 2012 10:15
-
-
Save akimboyko/4275479 to your computer and use it in GitHub Desktop.
Regex with {}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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