Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Detect presence of numbers 1-9

by jmcnamara (Monsignor)
on Apr 08, 2002 at 09:15 UTC ( #157391=note: print w/replies, xml ) Need Help??


in reply to Detect presence of numbers 1-9


You could use a regex to either match the characters that you want or alternatively to not match the characters that you don't want:
#!/usr/bin/perl -wl use strict; my $scalar = '1335'; print "Found" if $scalar =~ /^[1-5]+$/; print "Found" if $scalar !~ /[^1-5]/;

--
John.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2021-06-24 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (130 votes). Check out past polls.

    Notices?