Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Regex (lookahead) Confusion

by MCS (Monk)
on Feb 06, 2004 at 02:58 UTC ( [id://326974]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-16 06:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found