in reply to Re: Regex for weird characters
in thread Regex for weird characters

This goes with what DrHyde was showing with as a bunch of the normal characters you're looking for. It might take more characers depending on what else you want to add, but here you go.
if($text !~ m/^[a-z0-9,!,@,#,$,%,^,&,*,9,\,,\.\?,\~,:,\+,\-, ,\"]*$/i)


"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

Replies are listed 'Best First'.
Re^3: Regex for weird characters
by !1 (Hermit) on Sep 27, 2004 at 15:54 UTC
    Why do you have so many commas in your character class?
      Aren't you supposed to comma separate unsimilar items like that? I don't use regexes all that often but I did test the script and it worked.


      "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

      sulfericacid
        No, you aren't. Thus the reason that your a-z0-9 works fine. As a contribution to the thread:
        # cat match.pl #!/usr/bin/perl -l while (<DATA>) { chomp; print "$_ " . (/[^a-z0-9!\@#\$%^&*(),.?~:;<>+ =_'"-]/ ? "contains w +eird stuff":"is fine"); } __DATA__ funky town ^-^ b* f1 top` # perl match.pl funky town is fine ^-^ is fine b* is fine f1 is fine top` contains weird stuff #