如何在 JavaScript 中使用正则表达式来移除空格?
要移除 JavaScript 中的空格,你可以尝试运行以下正则表达式。它将从一个字符串中移除空格 −
示例
<html>
<head>
<script>
var str = "Welcome to Tutorialspoint";
document.write(str);
//Removing Spaces
document.write("<br>"+str.replace(/\s/g, ''));
</script>
</head>
<body>
</body>
</html>输出

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP