Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: specific numbers of digits

by pfaut (Priest)
on Mar 19, 2003 at 12:28 UTC ( [id://244318]=note: print w/replies, xml ) Need Help??


in reply to specific numbers of digits

Add a negative lookahead assertion to make sure the next character is not a digit: /\d{5}(?!\d)/

--- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';

Replies are listed 'Best First'.
Re: Re: specific numbers of digits
by hv (Prior) on Mar 19, 2003 at 17:05 UTC

    That will still match 6 digits, it'll just match the last 5 rather than the first 5. To match only 5 digits you need an assertion at both ends:

    m{ (?>! \d) # not after a digit \d(5} (?! \d) # not before a digit }x;

    Hugo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-26 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found