in reply to How to extract all alphanumeric characters from a string?

utf8::upgrade( my $alphanums = $chars ); $alphanums =~ s/[\W_]//g;
or
( my $alphanums = $chars ) =~ s/\P{Alnum}//g;

utf8::upgrade makes /\w/ match alphanums and "_", and /\W/ everything else.

Update: The original solution didn't remove underscores. Fixed.
Update: Added alternative method.