F
fishfry
How do I match a regex when the regex is stored in a variable, and has
modifiers? Example:
$string = 'abcdefg';
$regex = 'def';
if ($string =~ $regex) {
print "yes\n";
}
prints "yes".
However
$string = 'abcdefg';
$regex = 'DEF';
if ($string =~ $regex) {
print "yes\n";
}
of course does not print yes.
But
$string = 'abcdefg';
$regex = '/DEF/i';
if ($string =~ $regex) {
print "yes\n";
}
does not print yes either.
Any suggestions?
modifiers? Example:
$string = 'abcdefg';
$regex = 'def';
if ($string =~ $regex) {
print "yes\n";
}
prints "yes".
However
$string = 'abcdefg';
$regex = 'DEF';
if ($string =~ $regex) {
print "yes\n";
}
of course does not print yes.
But
$string = 'abcdefg';
$regex = '/DEF/i';
if ($string =~ $regex) {
print "yes\n";
}
does not print yes either.
Any suggestions?