I’m writing a short text token replacement system which takes the form:
$varName(opt1|opt2|opt3)
It’s designed to easily swap out things based on arbitrary values like this:
$gender(he|she)
I figured the best way to get and process those was a regex that matches the pattern but i can’t figure out how to recognise the options between the brackets because they can repeat an arbitrary number of times and may not have as many pipe characters as options.
Any help?
(I’m using C# as the regex host)
EDIT:
I tried this but it only seems to work with something with 2 options
\$[a-zA-Z]+\(([a-zA-Z]+\|)+[a-zA-Z]+\)
I figured it out.
I was forgetting to account for numbers in the options.