- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Write a Regular Expression to remove all special characters from a JavaScript String?
To remove all special characters from a JavaScript string, you can try to run the following code −
Example
<html> <head> <script> var str = "@!Welcome to our website$$"; document.write(str); // Removing Special Characters document.write("<br>"+str.replace(/[^\w\s]/gi, '')); </script> </head> <body> </body> </html>
Advertisements