I'm trying to match Lua block comments (and long strings) in the file format settings of Beyond Compare 3.
These are defined here: http://www.lua.org/manual/5.2/manual.html#3.1
Look for "long brackets" and "comments."
Here's a short description:
1. A comment marker, --, followed by an opening long bracket, which is a [, N equals signs, and another [.
2. The comment body, which is anything but a corresponding closing long bracket.
3. The closing long bracket, which is a ], another N equals signs, and another ].
N may be any number greater than 0, and is the same for both the opening and closing brackets. (Lua long strings have a similar format, sans the leading dashes.)
For example:
I figured that I could use a backreference to accomplish the matching, like so:
From:
--\[(=*)\[\
To:
\]\1\]
This doesn't work. Since I have no idea what BC3 adds in the middle, I also tried just a single expression:
--\[(=*)\[(.|\n)*\]\1\].
This didn't work either. I tested this one at http://regexpal.com/ to make sure it wasn't some mistake on my part, and it worked fine there.
It seems that BC3's regular expression system is having trouble with backreferences, perhaps? I may be missing something.
These are defined here: http://www.lua.org/manual/5.2/manual.html#3.1
Look for "long brackets" and "comments."
Here's a short description:
1. A comment marker, --, followed by an opening long bracket, which is a [, N equals signs, and another [.
2. The comment body, which is anything but a corresponding closing long bracket.
3. The closing long bracket, which is a ], another N equals signs, and another ].
N may be any number greater than 0, and is the same for both the opening and closing brackets. (Lua long strings have a similar format, sans the leading dashes.)
For example:
Code:
[COLOR="green"]--[[ comment is here ]][/COLOR]
Code:
[COLOR="green"]--[==[ comment [[also commented out]] still commented out ]==][/COLOR]
From:
--\[(=*)\[\
To:
\]\1\]
This doesn't work. Since I have no idea what BC3 adds in the middle, I also tried just a single expression:
--\[(=*)\[(.|\n)*\]\1\].
This didn't work either. I tested this one at http://regexpal.com/ to make sure it wasn't some mistake on my part, and it worked fine there.
It seems that BC3's regular expression system is having trouble with backreferences, perhaps? I may be missing something.
Comment