javascript - Replace two double quotes with single one using jquery -
how replace 2 double quotes single 1 using jquery?
for example: need replace
sam @ ""home""
to
sam @ "home"
looking similar regex (which replaces double quotes single quotes):
mystring.replace(/"/g, "'")
try this:
mystring = mystring.replace(/""/g, '"');
the regex captures 2 double quotes , replaces them one. we're using regex replace more single match (javascript's replace replace first one).
note second argument replace string. represent "
in string need escape it: "\""
, or use single quote string: '"'
. javascript supports both.
Comments
Post a Comment