Hi I want to replace single quote with two single quotes in a perl string.
If the string is <It's Simpson's book> It should become <It''s Simpson''s book>
echo "<It's Simpson's book>" | sed "s/'/''/g"
<It''s Simpson''s book>
perl -e '$p="<It'"'"'s Simpson'"'"'s book>";$p=~s/'"'"'/'"''"'/g;print $p,"\n";'
Thanks Pravin and Tene. I did not want to use sed inside perl script. By looking at Pravin's post I figured out the solution.
If the string is
It's Simpson's book
And I want it to become like
It''s Simpson''s book
And if the first string was stored in a variable $var then I used the foll code:
$var=~ s/\'/\'\'/g;
And it worked.
Thank you all.