Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
go ahead... be a heretic
 
PerlMonks  

Re: Regular expressions

by cees (Curate)
on Apr 13, 2005 at 09:43 UTC ( [id://447377]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Regular expressions

You already have some good answers, but here is another that just reverses your search (ie instead of searching for a-zA-Z it searches for anything that is not a-zA-Z and negates the answer):

$temp2 !~ m/[^a-zA-Z]/

This will return false if it finds a character that is not a-z or A-Z. The [^ ] only matches if none of the characters contained in the brackets are found.

You could reverse your condition to make the code easier to read with this method:

if ($temp2 =~ m/[^a-zA-Z]/) { die "Wrong input"; } else { $naam = $1; }

- Cees

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://447377]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.