Closed jprotze closed 6 years ago
Have you actually tested that this still does as intended, i.e. match quoted braces { or }. Actually within the text body, quoted braces are replaced in pre-processing, so the only place where this part of the pattern matters is when processing the arguments of context2cmds in the preamble and these contain a { or } combination. So in any case I accepted to avoid the warning messages. But currently it will probably erroneously fit constructions of the form " ... \{ some text } as might be encountered in a table, so will need a negative look-ahead pattern about preceding . I have to admit that I don't understand the pattern in your comment above.
Actually, I'm not sure that I understand the exact intended behavior for this pattern. My tests show, that the old and new pattern match the same text (at least for my selected text, couldnÄt attach it as .pl): pat_n.txt
For the first pattern, I get the warnings with current perl (5.24), no warnings with older (5.16). The second pattern provides the same match/no match results with both versions of perl.
As far as I understand the pattern, it accepts any \}
and \{
as either a non-curly match or a non-curly () followed by the curly match. The issue, that you mentioned affects both patterns, the look behind should solve this. Should the escaped brackets be balanced as well?
An alternative expression might be (but would actually capture the nested brackets, so ?1 would need to be adopted on use): ({(?:(?1)|[^{}]*+)++})
I'm using perl 5.24.1 and get multiple of warnings on execution.