Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to write a Regular Expression in JavaScript to remove spaces?
To remove spaces in JavaScript, you can try to run the following regular expression. It removes the spaces from a string −
Example
<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>
Output

Advertisements