The string built-in function Replace (Regexp, newstring) of JavaScript provides the string replacement function. From the function prototype, we can see that regular exp is supported. This function is very practical, but there are also a few obfuscation points. The following uses actual examples to illustrate:
For example
VaR src = "<a href = & quot; http://xx.com/a/20100601/000224.htm" target = & quot; _ blank & quot;> XXX </a>"
The Escape Character of the HTML double quotation marks to be replaced& Quot;For the actual"Normally, we will directly callSRC. Replace (/& quot;/g ,'"');To achieve the goal, but Javascript is easy to confuse. In this way, the SRC value is not actually changed. The actual test shows that the returned value is the result we need, SRC itself does not change, so we need to complete our functions as follows:
Src = SRC. Replace (/& quot;/g ,'"');