繁体   English   中英

Espace单/双引号内替换功能

[英]Espace single/double quotes inside replace function

我试图从一串转义字符中删除单引号和双引号。 它为单引号没有工作'或者双击汽车"

请有人帮忙吗?

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

试试这段剪辑的链式代码:

escape(
 unescape( mysting ).replace( /['"]/g, "" )
)

它很小但应该做你需要它做的事情。

^是表示字符串开头的锚点。 也就是说,如果字符串以%22开头 ,它只会进行替换。逻辑上,它只能从一个东西开始(显然是一个分号)。 我想你只想删除^

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM