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


in reply to Exception from a character class

You're already showing how to use a zero-width assertion, so why not use that to exclude the apsotrophe?

$text =~ s{(?!')\p{Punct}}{}g;
Alternately, how about
{ no warnings "uninitialized"; $text =~ s{(')|\p{Punct}}{$1}g; }

Update: a third solution is to match what you want to keep.

$text = join "", $text =~ m{[\x27\P{punct}]+}g;