Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by Roger (Parson)
on Dec 19, 2003 at 05:16 UTC ( [id://315746]=note: print w/replies, xml ) Need Help??


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

Hi leriksen, You were so close to getting it right, if you extend the regexp just a little bit with the match-time interpolation technique.
use strict; use warnings; while (<DATA>) { chomp; print m/(\d{1,20})(??{' ' x (20 - length($1))})/ ? "match\n" : "not match\n"; } __DATA__ " 123451234512345" " 123451234512345 " "123451234512345 " "1234512345 " "123 451 2345 " " "
And the output is exactly as expected -
not match not match match match not match not match

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (1)
As of 2025-01-18 11:38 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.