Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: REgular expression to check the string that allows "a","b" and "c" to occur only once in any order.

by KurtSchwind (Chaplain)
on Dec 11, 2007 at 05:43 UTC ( [id://656319]=note: print w/replies, xml ) Need Help??


in reply to Re: REgular expression to check the string that allows "a","b" and "c" to occur only once in any order.
in thread REgular expression to check the string that allows "a","b" and "c" to occur only once in any order.

Update: Nicely re-worked. Previously it didn't work but now it does. Nice job. I'm leaving my initial response here anyway, but it's no longer pertinent.

That doesn't work because it incorrectly matches invalid strings.

If you change

my $str="abc";
to
my $str="aaa";
You'll still get a match even though that's not supposed to be a valid string. You'll have to go a bit more complicated in the regex to exclude the false hits.

Update: I was missing my 2nd code snip.
--
I used to drive a Heisenbergmobile, but every time I looked at the speedometer, I got lost.
  • Comment on Re^2: REgular expression to check the string that allows "a","b" and "c" to occur only once in any order.
  • Select or Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 12:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found