Click to See Complete Forum and Search --> : remove double quotes from a string


helpcomm
09-17-2008, 09:57 AM
Hi,

say i have a variable $str as follows

$str = "\"hello\"";

so the content of str will be "hello" with the double quotes.

What shoud i do to remove the quotes?

Thanks

dragle
09-17-2008, 12:47 PM
Try:
$str =~ tr/"//d;
and see perldoc perlop (http://perldoc.perl.org/perlop.html#tr%2fSEARCHLIST%2fREPLACEMENTLIST%2fcds).

You can also use the substitution operator:
$str =~ s/"//g;
(also see perlop (http://perldoc.perl.org/perlop.html#s%2fPATTERN%2fREPLACEMENT%2fmsixpogce)), but in this case it will most likely be much slower.

Cheers!