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