Reputation: 11272
How do I remove all punctuation except for spaces from a string in Perl?
Upvotes: 0
Views: 9495
Reputation: 53976
Spaces aren't punctuation, and you aren't specific about whether you want to keep just spaces or all kinds of whitespace, but this substitution will remove all types of punctuation (since there are more forms of punctuation than just ! , and .).
$string =~ s/[[:punct:]]//g;
Upvotes: 6