I have the following code in my script.
if($description =~ /\'/) {
print "I am here\n";
$description =~ s/\'/'/g;
}
print "description = $description\n";
When I run this script, I don’t get the "I am here\n" output as the comparison fails.
But, when the $description string does contain an apostrophe.
$description = "The baseball player’s spiritual redemption and recovery from drug addiction.";
Context: I am parsing a string got from a call to nytimes bestsellers api(returned in json format) and this string is stored in $description string.
Your sample string doesn’t contain an apostrophe. It contains a
U+2019 RIGHT SINGLE QUOTATION MARK.It should match
/\x{2019}/