Greetings,

Consider the following snippet:

$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";
Running this (with either 5.6.1 or 5.8.0RC1:
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)
Uh? Am I missing something?
Cheers,
alf
You can't have everything: where would you put it?

In reply to Regex bug or head made of solid bone? by alien_life_form

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.