how to delete single quotes but not apostrophes in perl

perl

Solution

If you assume that a single-quote is always preceded or followed by whitespace, the following pair of regular expressions should work:

$line =~ s/\s'/ /g;  #preceded by whitespace
$line =~ s/'\s/ /g;  #followed by whitespace

you also need to account for if the string starts or ends with a single quote:

$str =~ s/^'//;  #at the start of a string
$str =~ s/'$//;  #at the end of a string

Problem

I would like to know how to delete single quotes but not apostrophes in perl. For example: 'It's raining again!' print It's raining again! Thanks so much

Original source