Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Regex help

by jreades (Friar)
on Nov 16, 2002 at 13:58 UTC ( [id://213394]=note: print w/replies, xml ) Need Help??


in reply to Regex help

If you want anything that isn't a digit or a leter (or an underscore), then you might consider using: \W

while ($in =~ /\W/) { # do something }

Or:

while ($in !~ /\w/) { ... }

Otherwise:

while ($in =~ /[^a-zA-Z0-9]/) { # do something }

Or:

while ($in !~ /[a-zA-Z0-9]/) { ... }

There's not much to chose between =~ and !~, but I generally like the emphasis of saying "as long as it's not one of these things..."

Replies are listed 'Best First'.
Re: Re: Regex help
by fruiture (Curate) on Nov 17, 2002 at 12:00 UTC

    Carefull with logic!

    $in =~ /\W/ # is NOT the same as $in !~ /\w/
    --
    http://fruiture.de

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 20:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found