如何在字符串中替换反斜杠双引号(例如\“)?
下面的代码不起作用。
<!DOCTYPE html>
<html>
<head>
</head>
<script type="text/javascript">
var myVar = '\"Things You Should Know\"';
document.write(myVar.replace(/\\\"/g, '|'));
</script>
<body>
<br>hello
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
var myVar = '\"Things You Should Know\"';
document.write(myVar.replace(/\"/g, '|'));
Run Code Online (Sandbox Code Playgroud)
该\转义下一个字符,以便您的字符串只读取"Things You Should Know"
| 归档时间: |
|
| 查看次数: |
8243 次 |
| 最近记录: |