如何使用JavaScript替换字符串中的所有点?
要替换字符串中的点,您需要转义点(。)并使用replace()方法进行替换。
示例
您可以尝试运行以下代码替换字符串中的所有点-
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
var str = 'Demo.Text.with.dots';
document.write("Text with dots- "+str);
var res = str.replace(/\./g,' ');
document.write("<br>Text without dots- "+res);
</script>
</body>
</html>