I’m new to Perl and regular expressions and I am having a hard time extracting a string enclosed by double quotes. Like for example,
"Stackoverflow is awesome"
Before I extract the strings, I want to check if it is the end of the line of the whole text was in the variable:
if($wholeText =~ /\"$/) #check the last character if " which is the end of the string
{
$wholeText =~ s/\"(.*)\"/$1/; #extract the string, removed the quotes
}
My code didn’t work; it is not getting inside of the if condition.
You need to do:
.doesn’t match newlines unless you apply the/smodifier.There’s no need to escape the quotes like you’re doing.