Anyway I can put the the data matching in a variable??You can use the qr// construct to build regular expression objects e.g
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.gmy $re = qr/(?:match|matching\.com|match.company)/i; print "regexp - $re"; __output__ regexp - (?i-xsm:(?:match|matching\.com|match.company))
See. perlre for more info on regexes in perl.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
_________
broquaint
In reply to Re: Variable in pattern matching line
by broquaint
in thread Variable in pattern matching line
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |