Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Regex help

by jreades (Friar)
on Nov 16, 2002 at 13:58 UTC ( #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 }


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


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


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/

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://213394]
[jedikaiti]: Pretty!
[erix]: ( TBH, I think it's a load of bull -- but maybe I'm mistaken )
[erix]: Hey that's Hungary - wave down ambrus and tell him to reboot his systems!
[choroba]: it might be a problem if you expect to reach the maximal possible value soon without squashing the ids
[erix]: that's really impossible with bigint
[erix]: and the site is still only 'hopefully' active :)
[erix]: but fair enough, he may think he solves a problem

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2017-06-23 15:45 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (551 votes). Check out past polls.