Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Regular Expression from Hell

by perlmonkey (Hermit)
on Apr 15, 2004 at 15:34 UTC ( #345417=note: print w/replies, xml ) Need Help??


in reply to Regular Expression from Hell

I think what you are looking for is:
if( $test =~ /^\d{4}$/ ) { ... }
This will match:
'^': anchor start of string
\d{4}: exactly 4 digits
$: anchor end of string

if you know it is always going to be digits, then length would probably be eaiser:
if( length($test) == 4 ) { ... }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://345417]
help
Chatterbox?
[Discipulus]: perl dreams to you all
[marioroy]: LA my @music_times = qx(find \$HOME/Music/ Albums -type f -iname \'*.mp3\' -exec mp3info -p \"%S\\n\" {} \\;);
[marioroy]: Only 2 backslash \\n
[marioroy]: LA no space before Albums
[Lady_Aleena]: Good guh! I think I will use File::Find when working in perl. That is too many toothpicks.
[marioroy]: mp3info must be in the PATH

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2017-04-23 21:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.