Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Regex to match 20 chars of some digits followed by some spaces

by BrowserUk (Patriarch)
on Dec 19, 2003 at 06:53 UTC ( [id://315755]=note: print w/replies, xml ) Need Help??


in reply to Regex to match 20 chars of some digits followed by some spaces

Here's my attempt which seems a little simpler than some of the others.

m[^ \d (?: (?<! \x20 ) \d | \x20 ){19} $]x

Which says that the entire string must constist of a digit followed by 19 ((digits not preceeded by spaces) or spaces).

print m[^ \d (?: (?<!\x20) \d | \x20 ){19} $]x ? 'Yes:' . $_ : ' No:' . $_ for @t; No: 123451234512345 No: 123451234512345 Yes:123451234512345 Yes:1234512345 No:123 451 2345 No:

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (None)
    As of 2025-01-18 11:50 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Which URL do you most often use to access this site?












      Results (56 votes). Check out past polls.