I am trying to remove single and double quotes from a string of escaped characters. It does no work for single quotes '
or double autos "
.
Please could somebody help please?
var mysting = escapedStr.replace(/^%22/g, ' '); //doesnt remove the double quotes
var mysting = escapedStr.replace(/^%27/g, ' '); //doesnt remove the single quotes
var mysting = escapedStr.replace(/^%3A/g, ' '); //does remove the SEMI COLON %3A
Try this snipped of chained code:
escape(
unescape( mysting ).replace( /['"]/g, "" )
)
Its small but should do what you need it to do.
The ^
is an anchor indicating the start of the string. That is, it will only do the replacement if the string starts with %22
, etc. Logically, it can only start with one thing (apparently a semi-colon). I think you just want to remove the ^
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.