jbryan has asked for the wisdom of the Perl Monks concerning the following question:
Regex gurus: How do I NOT match something inside something else? E.g. I want to match X but not if its in braces {X}?
Example:
I want to replace all newlines (\n) with (\n<br>), but not if they are inside double-braces. For example:
my $data = q| foo bar {{ alpha beta }} baz |;
In $data, above, the lines with 'foo' and 'bar' should have the <br> added, but the lines with 'alpha' and 'beta' should not be touched.
Am I just missing something simple in perlre that would make this work? I don't even know where to start - other than some non-regex solution entirely.
Back to
Seekers of Perl Wisdom