in reply to validating form input

What do you mean by "restrict"? Do you want to replace characters that aren't alphanumeric with something else? Do you simply want to know if the string contains non-alphanumeric characters, so that you can act appropriately?

Linda

Replies are listed 'Best First'.
Re: Re: validating form input
by jwlarson3rd (Acolyte) on Feb 25, 2004 at 19:40 UTC
    I would like to delete everything but large and small case letters and numbers john larson
      How about this?

      # replace non alphanumeric characters with '' $name =~ s/\W//g; # replace '_' with '' because \W doesn't catch those $name =~ s/_//g;

      Linda

      perl -e "my $t = \"ABC def 123*GHI;?. jk\"; $t =~ s/([^A-Z0-9 ])*//ig; + print $t;## don't accept any char. except... _______^"
      ...

      ABC def 123GHI jk

      You want the tr (transliteration) operator:

      $name =~ tr/A-Za-z0-9//cd;

       --
      LP^>