in reply to Regex (lookahead) Confusion

It doesn't pertain to your question but the code:

$string =~ /^[smtwhfa]*$/

The * is zero or more, not one or more. For one or more use the + sign. (So it would be /^[smtwhfa]+$/) Unless instead of saying

"A user supplied string may contain 1 or more of the characters smtwhfa in any order."
you really meant zero or more. Just a frequent mistake some people make that I thought I would point out.

Replies are listed 'Best First'.
Re: Re: Regex (lookahead) Confusion
by ChrisR (Hermit) on Feb 06, 2004 at 13:28 UTC
    Like Zaxo said above, you are right about the difference between the * and the +. However, I did mean the string must contain 1 or more characters of the allowed class. I just got my quantifier wrong. Thanks to both you and Zaxo for pointing out the mistake.