Good trick. But when s/($profanity)/eval '"'.$profane{$1}.'"'/ge turns to s/($profanity)/lift $1 off/g, doesn't it give you "life piss you off off" since "piss you off" is what being captured into $1?

Consider this:
$_ = "candies lift me up"; s/(cand(y|ies)|lift(s|) (me|us) up)/1 $1; 2 $2; 3 $3; 4 $4;\n/g; print ; __END__ 1 candies; 2 ies; 3 ; 4 ; 1 lift me up; 2 ; 3 ; 4 me;
"me" is captured in $4. In other words, we don't know ahead of time which of the $1 .. $n "me" will end up in when the regex can have arbitrary many brackets.

In reply to Re: Re: Turn Hate Mail to Love Letter: Regex Multi-Word/Phase Replace by chunlou
in thread Turn Hate Mail to Love Letter: Regex Multi-Word/Phase Replace by chunlou

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.