Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Need help comparing against a set of regexps

by seattlejohn (Deacon)
on Mar 10, 2002 at 08:09 UTC ( #150692=note: print w/replies, xml ) Need Help??

in reply to Need help comparing against a set of regexps

You don't want the "o" suffix on your regex. In if ($a =~ /$b/o), the "o" is making a promise that you won't change the value of $b, so perl doesn't recompile the regex for each $b you create. You probably do want the "i" suffix to make the matching case-insensitive -- otherwise 'Hello' will not match 'hello'! Consider this a starting point:
'Hello(world)' =~ m/hello\(\w+\)/i  # is true

Replace the right side with the variable containing the current regex you want to match and you will be on your way.

BTW, it's generally a good idea to avoid using the variable names $a and $b because they have a special significance to perl (see perldoc -f sort).

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2022-01-25 22:57 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (69 votes). Check out past polls.