alien_life_form has asked for the wisdom of the Perl Monks concerning the following question:
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex bug or head made of solid bone?
by Abigail-II (Bishop) on Jun 06, 2002 at 18:32 UTC | |
by alien_life_form (Pilgrim) on Jun 07, 2002 at 09:06 UTC | |
|
Re: Regex bug or head made of solid bone?
by vladb (Vicar) on Jun 06, 2002 at 13:30 UTC | |
by alien_life_form (Pilgrim) on Jun 06, 2002 at 17:06 UTC |