Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Executing a "/foo/flags" regex from a string (qr flags)

by Anonymous Monk
on Dec 30, 2015 at 01:52 UTC ( [id://1151416]=note: print w/replies, xml ) Need Help??


in reply to Executing a "/foo/flags" regex from a string

qr can do it as perlre syntax allows (?i) the same as /i

$ perl -le " print int q{shoes} =~ /SHOES/ " 0 $ perl -le " print int q{shoes} =~ /SHOES/i " 1 $ perl -le " print int q{shoes} =~ /(?i)SHOES/ " 1

App::Ack uses this trick

You can use eval { no re qw/eval/; qr/$regex/ }; to see if the regex compiles

See also Text::Glob#glob_to_regex

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1151416]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 14:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found