I'm trying to create a small app that takes a base text template with specially tagged word arrays, parses the template contents and outputs a randomly generated text document.
Essentially, what I'm trying to do is take this:
<{Hello|Hi|Howdy}> world.
and turn it into this:
Hello world. OR Hi world. OR Howdy world.
So far, so good. Googling got me enough to be able to successfully extract the inner text between the <{ and }> into an array, from which I then randomly select a word to replace the full <{Hello|Hi|Howdy}>.
The problem I'm having is parsing a nested set of words wrapped in the same tags.
For example, if I start with this:
<{Hello|Hi|Howdy}> world. <{How's <{life|it going}>?|How are you?}>
I'd like to turn it into this:
Hello world. How's life? OR Hello world. How's it going? OR Hello world. How are you?
and so on...
Could someone suggest a way to do this fairly simply using c# and regex?
I've looked at http://www.vsj.co.uk/articles/display.asp?id=789 and http://www.m-8.dk/resources/RegEx-balancing-group.aspx, and to be honest, a lot of that goes way over my head, so something simple would be nice. ;-)
Thank you.