in reply to set value of a variable to a regexp
printsuse Regexp::Assemble; my $r = Regexp::Assemble->new->track(1)->add(qw(foo? bar{2} [Rr]at)); for my $w (qw(this food is rather barren)) { if ($w =~ /$r/) { print "$w matched by ", $r->source($^R), $/; } else { print "$w no match\n"; } }
this no match food matched by foo? is no match rather matched by [Rr]at barren matched by bar{2}
|
|---|