Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

by oha (Friar)
on Dec 11, 2007 at 10:12 UTC ( [id://656363]=note: print w/replies, xml ) Need Help??


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

print "ok!\n" unless /([abc]).*\1/;
the RE above checks if one of [abc] is repeated

if you want to declare "abcz" wrong too, just:

print "ok!\n" unless /(([abc]).*\2|[^abc])/;
which also check if a bad char is present.

Oha

  • Comment on Re: 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://656363]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found