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

Re: RegExp madness

by CombatSquirrel (Hermit)
on May 16, 2004 at 21:14 UTC ( [id://353821]=note: print w/replies, xml ) Need Help??


in reply to RegExp madness

I wouldn't consider myself a Perl expert, so I won't comment on the others' replies, which certainly are correct. However, Perl (the newer versions anyways) supports dynamic RegEx creation, so you might want consider using the following to get the desired results (it does seem to work ;-):
$_ = '511111'; print /^(\d)(??{"\\d{$1}"})$/ ? 'yay' : 'oops';
Hope this helped.
CombatSquirrel.
Entropy is the tendency of everything going to hell.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-16 21:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found