Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Should be a simple spaces/digits regex....but I'm turning grey!

by Bethany (Scribe)
on Aug 05, 2014 at 02:11 UTC ( [id://1096229]=note: print w/replies, xml ) Need Help??


in reply to Should be a simple spaces/digits regex....but I'm turning grey!

If only digits and space characters are allowed in the string, forget the (numeric) quantifiers and just check for the conditions you described; zero or more spaces followed by one or more digits; anchored fore and aft (at the beginning and end of the string) so nothing can come before the optional spaces and nothing after the digits:

^\s*\d+$

If characters other than digits and spaces may appear, I'd go for a coded solution rather than trying to concoct a single regex to do it all.

(Edited to add "numeric")

  • Comment on Re: Should be a simple spaces/digits regex....but I'm turning grey!
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (None)
    As of 2024-04-25 03:54 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found