如何从字符串中删除`// `

如何从字符串中删除//<![CDATA[和结束//]]>

 var title = "" ; 

需要成为

 var title = "A Survey of Applications of Identity-Based Cryptography in Mobile Ad-Hoc Networks"; 

怎么做?

您可以使用String.prototype.replace方法,如:

 title = title.replace("", ""); 

这将替换每个目标子字符串。 请注意,这只会替换每个匹配项的第一个匹配项,如果要删除所有匹配项,则需要使用正则表达式。

参考:

你应该能够用正则表达式做到这一点。 也许是这样的?:

 var myString = ""; var myRegexp = //; var match = myRegexp.exec(myString); alert(match[1]);