Reputation: 105213
I'm trying to use a string as a regular expression inside another regular expression:
my $e = "a+b";
if ('foo a+b bar' =~ /foo ${e} bar/) {
print 'match!';
}
Doesn't work, since Perl treats +
as a special character. How do I escape it without changing the value of $e
?
Upvotes: 3
Views: 63