Simple C# Tokenizer Using Regex

Posted by Pete on Stack Overflow See other posts from Stack Overflow or by Pete
Published on 2010-05-20T12:36:33Z Indexed on 2010/05/20 12:40 UTC
Read the original article Hit count: 433

Filed under:
|
|

I'm looking to tokenize really simple strings,but struggling to get the right Regex.

The strings might look like this:

string1 = "{[Surname]}, some text... {[FirstName]}"

string2 = "{Item}foo.{Item2}bar"

And I want to extract the tokens in the curly braces (so string1 gets "{[Surname]}","{[FirstName]}" and string2 gets "{Item}" and "{Item2}")

this question is quite good, but I can't get the regex right: poor mans lexer for c# Thanks for the help!

© Stack Overflow or respective owner

Related posts about regex

Related posts about c#