Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Help with a more precise regex

by asdfgroup (Beadle)
on Apr 26, 2003 at 00:25 UTC ( [id://253292]=note: print w/replies, xml ) Need Help??


in reply to Help with a more precise regex

Hi, This one should work fine and detect all "format errors":
for ("2D 3h", "2d", "3h", "3h 2d", "Some string") { my ($day, $hour) = map {$_+0} /^(?:(\d+)d\s*)?(?:(\d+)h)?$/i; $day || $hour ? print "Day - $day, hour - $hour\n" : warn "Wrong fo +rmat $_" }
Sincerely, Nikita Savin

Log In?
Username:
Password:

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

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

    No recent polls found