[regex] Perl regex special characters

Hi http://www.boost.org/libs/regex/doc/syntax_perl.html http://www.boost.org/libs/regex/doc/syntax_perl.html says: Perl Regular Expression Syntax In Perl regular expressions, all characters match themselves except for the following special characters: .[{()\*+?|^$ Q: what about "]}" symbols? Best regards, Andriy Tylychko, telia@vichnavich.com www.vichnavich.com http://www.vichnavich.com/

# telya@mail.ru / 2006-09-08 12:23:36 +0300:
Hi
http://www.boost.org/libs/regex/doc/syntax_perl.html http://www.boost.org/libs/regex/doc/syntax_perl.html says:
Perl Regular Expression Syntax
In Perl regular expressions, all characters match themselves except for the following special characters:
.[{()\*+?|^$
Q: what about "]}" symbols?
They're only special if there's a matching "[" or "{" earlier in the pattern: > echo 'aaa]}]}]}bbb' | perl -pe 's/(]|})+//' aaabbb > echo 'aaa]}]}]}bbb' | perl -pe 's/[]}]+//' aaabbb > echo 'aaa}}}]]]bbb' | perl -pe 's/}+//;s/]+//' aaabbb -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991

From: Roman Neuhauser [mailto:neuhauser@sigpipe.cz] # telya@mail.ru / 2006-09-08 12:23:36 +0300:
Hi
http://www.boost.org/libs/regex/doc/syntax_perl.html http://www.boost.org/libs/regex/doc/syntax_perl.html says:
Perl Regular Expression Syntax
In Perl regular expressions, all characters match themselves except for the following special characters:
.[{()\*+?|^$
Q: what about "]}" symbols?
They're only special if there's a matching "[" or "{" earlier in the pattern:
> echo 'aaa]}]}]}bbb' | perl -pe 's/(]|})+//' aaabbb > echo 'aaa]}]}]}bbb' | perl -pe 's/[]}]+//' aaabbb > echo 'aaa}}}]]]bbb' | perl -pe 's/}+//;s/]+//' aaabbb
Moving this discussion from boost-users to boost-development... Thanks for explanation, Roman. I've checked this on boost v.1.33.1, but only unmatched "]" is allowed, construction of boost::regex("}") claims unmatched "}". Is it by design or already fixed in v.1.34? I had to handle special characters, so I just "copy/paste"ed from docs. And so, I didn't handle "}]". Do you think it's a good idea to expand description of special characters in docs to include explanation about "}]" characters? As I checked, both unmatched "]" (and probably "}" in 1.34) and unmatched but escaped "\}\]" are allowed and have the same effect. It was very useful for me, so maybe it's worth to mention in docs too. Thanks, Andriy.

Andriy Tylychko (mail.ru) wrote:
Moving this discussion from boost-users to boost-development...
Thanks for explanation, Roman.
I've checked this on boost v.1.33.1, but only unmatched "]" is allowed, construction of boost::regex("}") claims unmatched "}". Is it by design or already fixed in v.1.34?
I had to handle special characters, so I just "copy/paste"ed from docs. And so, I didn't handle "}]". Do you think it's a good idea to expand description of special characters in docs to include explanation about "}]" characters? As I checked, both unmatched "]" (and probably "}" in 1.34) and unmatched but escaped "\}\]" are allowed and have the same effect. It was very useful for me, so maybe it's worth to mention in docs too.
I'll take a look at this, there are no changes in Boost-1.34 BTW. John.
participants (3)
-
Andriy Tylychko (mail.ru)
-
John Maddock
-
Roman Neuhauser