More issues with brat_n / pat_n
Closer testing after PR #120 showed that also the brat_n pattern has issues: I think, when reading the string, a backslash escapes the following backslash. Only if there is no character, that needs escaping, the backslash is read as backslash.
The regexp to match '[' is m/\[/. For the regexp, both backslash and bracket need to be escaped. When assigning $p='\[', the result in $p is actually '\['. The first backslash escapes the second, the third has nothing to escape, so character.
The regex, as currently in the script is parsed to "\[|\]" and matches backslash followed by pipe or backslash.
$pat_n = '\\\[|\\\]';
print "pat_n=".$pat_n."\n";
test('\[');
test('\|');
test('\\\\');
Attached the two test scripts, I used to test the patterns: brat_n.txt pat_n.txt
The other point, that is unclear to me is, whether the intent of the patterns is to match pairs of escaped brackets or stand alone escaped brackets.
Updating to Ubuntu 17/10 brought perl 5.26. This version of perl actually throws an error for the un-escaped {, glad that this is already fixed :D
Is this still an issue in the github version. Your last comment seems to indicate it is solved and can be closed?
The point of pat_n pattern is to match any text containing matching (unquoted) {} pairs including nesting, or text containing no parentheses. It should ignore escaped {, }, i.e. treat them identically to any other character.