Hello monks! I am generally ok with regexes but this one has me stumped. I am doing a massive search and replace operation across a few hundred pages and I seem to have a problem getting my match found. I have enough code below to recreate the problem.... (the href reference is an exact cut and paste).

#!/usr/bin/perl $text = 'YAY! <a href="/cgi-bin/ruling?candy=265-23&path=/rules/other/ +265-23&file_num=265-23&action=Show_Form" class="subCat9">Click to sub +mit</a> YAY!'; $find='<a href="/cgi-bin/ruling?candy=265-23&path=/rules/other/265-23& +file_num=265-23&action=Show_Form" class="subCat9">Click to submit</a> +'; $replace="This is a replacement"; # Would like to see # YAY! This is a replacement YAY! $text=~s/$find/$replace/g; print $text; # I get # YAY! <a href="/cgi-bin/ruling?candy=265-23&path=/rules/other/265-23& +file_num=265-23&action=Show_Form" class="subCat9">Click to submit</a> + YAY!


I am guessing it's some sort of interpolation issue maybe? Does anyone have a clue ?
Thank you so much for your advice. Sherab

In reply to Regex can't find match by sherab

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.