Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Pattern matching regex problem

by Corion (Patriarch)
on Nov 23, 2021 at 08:46 UTC ( [id://11139045]=note: print w/replies, xml ) Need Help??


in reply to Pattern matching regex problem

tr doesn't take character classes in square brackets ([]), so your code can also be written as:

if (0 == $s =~ tr/IOSM//c) {

Your code counts whether there is any of the letters I, O, S or M in the string. Which is obviously true.

Maybe you wanted to match the letters in order?

m/I+O+S+M+/

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-03-28 22:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found