Consider the following snippet:
Running this (with either 5.6.1 or 5.8.0RC1:$orig='aaa([\+\-]{1})bbb'; $qre="\\Q([\\+\\-]{\\E\\d\\Q})\\E"; $bre='\(\[\\\\\+\\\-\]\{\d\}\)'; $str=$orig; $str =~ s!\Q([\+\-]{\E\d\Q})\E!!; print "Replace against literal quoted: $str\n"; $str=$orig; $str =~ s!\(\[\\\+\\\-\]\{\d\}\)!!; print "Replace against literal bslashed: $str\n"; $str=$orig; $str =~ s!$qre!!; print "Replace against variable quoted => $qre <=: $str\n"; $str=$orig; $str =~ s!$bre!!; print "Replace against variable bslashed => $bre <=: $str\n";
Uh? Am I missing something?c:\temp> D:\perl58\bin\perl.exe re.pl D:\perl58\bin\perl.exe re.pl Replace against literal quoted: aaabbb Replace against literal bslashed: aaabbb Replace against variable quoted => \Q([\+\-]{\E\d\Q})\E <=: aaa([\+\-] +{1})bbb Replace against variable bslashed => \(\[\\\+\\-\]\{\d\}\) <=: aaabbb c:\temp>perl re.pl perl re.pl Replace against literal quoted: aaabbb Replace against literal bslashed: aaabbb Replace against variable quoted => \Q([\+\-]{\E\d\Q})\E <=: aaa([\+\-] +{1})bbb Replace against variable bslashed => \(\[\\\+\\-\]\{\d\}\) <=: aaabbb C:\temp\perl -v This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail)
In reply to Regex bug or head made of solid bone? by alien_life_form
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |