in reply to Re: check if string contains anything other than alphanumeric
in thread check if string contains anything other than alphanumeric

$ perl -le 'print "hello_world" =~ /^\w+$/ ? "OK" : "BAD"' OK ---> underscore is considered alphanumeric character.
Underscore is not considered an alphanumeric character. It is considered a word character (hence the \w character class.)

Replies are listed 'Best First'.
Re^3: check if string contains anything other than alphanumeric
by naikonta (Curate) on Aug 12, 2007 at 14:08 UTC
    It's said that \w matches a 'word' character (alphanumeric plus '_'), so I should have said that "underscore is considered part of that character class". Thank you, jwkrahn.

    Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!