Help for this page

Select Code to Download


  1. or download this
    $ perl -le 'print "hello world" =~ /^\w+$/ ? "OK" : "BAD"'
    BAD ---> contain spaces
    ...
    OK
    $ perl -le 'print "hello_world" =~ /^\w+$/ ? "OK" : "BAD"'
    OK ---> underscore is considered alphanumeric character.
    
  2. or download this
    $ perl -le 'print "hello_world" =~ /^[a-zA-Z0-9]+$/ ? "OK" : "BAD"'
    BAD ---> underscore is not in the class
    
  3. or download this
    $ perl -le 'print "hello world" =~ /^[[:alnum:]]+$/ ? "OK" : "BAD"'
    BAD ---> space is not alnum
    ...
    BAD ---> _ is not alnum
    $ perl -le 'print "HelloWorld1" =~ /^[[:alnum:]]+$/ ? "OK" : "BAD"'
    OK --> nothing there but letters and digits