http://www.perlmonks.org?node_id=338451


in reply to leaving only [a-zA-Z0-9]

you can also use $a =~ s/\W//g;

If you use locales; it supports special chars too.

Replies are listed 'Best First'.
Re: Re: leaving only [a-zA-Z0-9]
by Happy-the-monk (Canon) on Mar 21, 2004 at 14:18 UTC

    you can also use $a =~ s/\W//g;

    make that   s/[\W_]//g;   to take away the   _   too.

    And careful with   locale!   That will not get rid of Umlauts and word characters with accents and such. It will still get rid of special characters though.

    Sören

      "That will not get rid of Umlauts and word characters with accents and such." - that are the specialchars I've meant.
      Sorry I should have been more detailed in my explanation.