

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
- Related Questions & Answers
- How to remove white spaces using Java Regular Expression (RegEx)
- Write a Regular Expression to remove all special characters from a JavaScript String?
- How to write JavaScript Regular Expression for multiple matches?
- How to write a Python regular expression to use re.findall()?
- How to write a Python Regular Expression to validate numbers?
- How to strip spaces/tabs/newlines using Python regular expression?
- How to define a Regular Expression in JavaScript?
- How to write Python regular expression to check alphanumeric characters?
- How to write a Python regular expression to get numbers except decimal?
- How to write a Python regular expression to match multiple words anywhere?
- How to write a case insensitive Python regular expression without re.compile?
- How to write Python Regular Expression find repeating digits in a number?
- How to write a regular expression to match either a or b in Python?
- How to write Python regular expression to match with file extension?
- How to write a Python regular expression that matches floating point numbers?
Advertisements