Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by Roy Johnson (Monsignor)
on Dec 19, 2003 at 20:17 UTC ( [id://315897]=note: print w/replies, xml ) Need Help??


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

Excellent. Piqued my interest in this approach, which led to a few observations:
  • you probably want to anchor your match
  • you could have used dot-star instead of .{0,18}, or you could have specified the chars for the dot (TIMTOWTDI) -- probably the most efficient thing would be to specify (?!\d* +\d), which made me realize...
  • it can be done with a positive lookahead like so: /^\d(?=\d* *$)[\d ]{19}$/ ("leading digit, followed by digits, then spaces, then end of string, etc.")

The PerlMonk tr/// Advocate

Replies are listed 'Best First'.
Re: Re:^2 Regex to match 20 chars of some digits followed by some spaces
by ysth (Canon) on Dec 21, 2003 at 01:40 UTC
    I actually have never used Parse::RecDescent but was assuming it was working on an input buffer using the supplied regex as something like /\G$regex/gc so I didn't supply a beginning anchor and an ending anchor is not usable. I haven't got around to checking my assumption yet...and you know what they say when you assUme.
      Well, I've read through Parse::RecDescent and it does work as I had guessed. So solutions to this problem should not have ^ and may not depend on $.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2025-01-18 09:27 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.