From your expected results, I deduce you actually want a string that is surrounded by {...}, or one that is neither preceded by { nor followed by }.
That's correct: I want the string, optionally surrounded by braces. One brace on only one side is not acceptable. I'm glad that my listing of expected results was clearer than my description. ;-)
Your alternation approach certainly functions. However, I was also hoping to learn to use the conditional ( (?(COND)...) ) notation. So you answered the question I asked (thanks!); but left me with the one I didn't ask.
For my own education, can you think of a solution that uses the conditional notation, or would I be horribly abusing said to solve this problem?
In reply to Re^2: Regex conditional match if previous match in same expression is true?
by radiantmatrix
in thread Regex conditional match if previous match in same expression is true?
by radiantmatrix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |