- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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
Let’s say the following is our string with special characters −
var sentence = '<My<Name<is<John<Doe';
We are replacing the special character and setting a space with it using replace() along with regex.
Following is the code −
var sentence = '<My<Name<is<John<Doe'; var regularExpresion = /<(?!\s)/g; var result = sentence.replace(regularExpresion, "< "); console.log(result);
To run the above program, you need to use the following command −
Here, my file name is demo271.js
This will produce the following output on console −
- Python program to replace all Characters of a List except the given character
- MySQL query to replace special characters from column value
- C# Program to replace a special character from a String
- How to escape all special characters for regex in Python?
- Java Program to replace one specific character with another
- MySQL: How can I find a value with special character and replace with NULL?
- Program to replace all digits with characters using Python
- Java Program to replace all occurrences of a given character with new character
- How to remove all special characters, punctuation and spaces from a string in Python?