[英]Javascript-escape special characters in xml
I have an xml which has the string "/" in it multiple times I need to replace it with "/" can somebody help with the regex. 我有一个XML,其中多次包含字符串“ /”,我需要将其替换为“ /”,有人可以帮忙使用正则表达式。
i tried : 我试过了 :
Val.replace(\//g, '/')
But that doesnt work. 但这不起作用。
Your regex format isn't quite right, you have: 您的正则表达式格式不太正确,您有:
Val.replace(\//g, '/')
When JS regex is always between the '/' characters, like so: 当JS正则表达式始终位于'/'字符之间时,如下所示:
/<REGEXGOESHERE>/g
In your case you are looking for (I think, your message is slightly confusing as it says you want to replace '/' with '/' which doesn't make sense, so I assumed you were saying replace '\\' with '/') 在您的情况下,您正在寻找(我认为,您的消息有些混乱,因为它说您想用'/'替换'/',这没有意义,所以我假设您是在用'/替换'\\' ')
Val.replace(/[\]/g, '/')
Here's a useful tool for debugging regex: 这是调试正则表达式的有用工具:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.