Javascript character replace all
This question already has an answer here:
You're almost there.
the thing you saw in SO is regex replace :
document.write(test.replace(/?/g,"&"))
( I thought you wanted to change & to ? , but you want the opposite.)
with the G flag - it will replace all the matches in the string
without it - it will replace only the first match.
You need to escape the ? character like so:
test.replace(/?/g,"&")
链接地址: http://www.djcxy.com/p/16844.html
上一篇: charsets替换问题
下一篇: Javascript字符全部替换