Anyway I can put the the data matching in a variable??
You can use the qr// construct to build regular expression objects e.g
my $re = qr/(?:match|matching\.com|match.company)/i; print "regexp - $re"; __output__ regexp - (?i-xsm:(?:match|matching\.com|match.company))
You might also want to consider Regex::PreSuf. Another thing to note is that due to the nature of alternation in perl's regex engine anything with 'match' will always match (regardless of the 'ing.com' or '.company'), making the other two alternations redundant. So you'll want to reverse the order of the alternation groups e.g
my $re = qr/(match|matching\.com|match.company)/i; print "old - $1\n" if "matching.com" =~ $re; $re = qr/(matching\.com|match.company|match)/i; print "new - $1\n" if "matching.com" =~ $re; __output__ old - match new - matching.com
See. perlre for more info on regexes in perl.
HTH

_________
broquaint


In reply to Re: Variable in pattern matching line by broquaint
in thread Variable in pattern matching line by Anonymous Monk

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.