in reply to Executing a "/foo/flags" regex from a string
perl -E 'my $str = "/regex/i"; my ($pat, $flags) = $str =~ m{^/(.+)/([imsx]*)\z} ? ($1, $2) : die "Bad regex"; my $qr = qr/(?$flags:$pat)/; say qq{Matched "$_" with $qr} for grep {$_ =~ $qr} qw(foo bar baz reGex)' Matched "reGex" with (?^u:(?i:regex))
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Executing a "/foo/flags" regex from a string
by Radiola (Monk) on Dec 30, 2015 at 18:05 UTC |