You should use the string replace function, with a single regex. Assuming by special characters, you mean anything that's not letter, here is a solution:

const str = "abc's test#s";
console.log(str.replace(/[^a-zA-Z ]/g, ""));
Run code snippetEdit code snippet Hide Results Copy to answer Expand

Answer from Petar Ivanov on Stack Overflow
🌐
CoreUI
coreui.io › answers › how-to-remove-special-characters-from-a-string-in-javascript
How to remove special characters from a string in JavaScript · CoreUI
May 20, 2026 - Use replace() with regular expressions to efficiently remove special characters from strings in JavaScript.
Discussions

javascript - Remove all special characters with RegExp - Stack Overflow
I would like a RegExp that will remove all special characters from a string. I am trying something like this but it doesn’t work in IE7, though it works in Firefox. var specialChars = "!@#$^&%... More on stackoverflow.com
🌐 stackoverflow.com
javascript - Regex remove all special characters except numbers? - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
🌐 stackoverflow.com
javascript - how to remove Characters from a string in react.js - Stack Overflow
I'm receiving data in this form ('FCA',) ('JP NIC',) ('JP CHI',) ('2022-03-04T07:18:36.468Z',) I want to clean up to remove Brackets, string quote and comma FCA JP NIC JP CHI 2022-03-04T07:18:36.4... More on stackoverflow.com
🌐 stackoverflow.com
Javascript regex - remove all special characters except semi colon - Stack Overflow
In javascript, how do I remove all special characters from the string except the semi-colon? sample string: ABC/D A.b.c.;Qwerty should return: ABCDAbc;Qwerty More on stackoverflow.com
🌐 stackoverflow.com
May 2, 2012
🌐
CodeSandbox
codesandbox.io › s › remove-special-characters-from-string-in-react-js-suhr8h
remove-special-characters-from-string-in-react-js - CodeSandbox
July 12, 2022 - remove-special-characters-from-string-in-react-js by infinitbility using react, react-dom, react-scripts
Published   Jul 12, 2022
Author   infinitbility
🌐
thisPointer
thispointer.com › home › javascript › javascript: string remove special characters
Javascript: String remove special characters - thisPointer
August 2, 2021 - Here, in the above replace() method the regular expression states to replace all characters except the numbers. ... The same replace() method will be used in the below code to remove the special characters but keep the spaces (” “) and ...
🌐
IQCode
iqcode.com › code › javascript › js-remove-special-characters
js remove special characters Code Example
October 16, 2021 - //You can do it specifying the characters you want to remove: string = string.replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, ''); //Alternatively, to change all characters except numbers and letters, try: string = string.replace(/[^a-zA-Z0-9]/g, ''); ... Unlock the power of data and AI ...
🌐
Abacadvor
sfa.abacadvor.site › javascript-remove-special-characters-from-string-except-dot.html
Javascript remove special characters from string except dot. Remove all special characters except space from a string using JavaScript
Featured on Meta. Feedback on Q2 Community Roadmap.Example we are replacing the dots. Output: Split and Join : We can split up strings of text with the Javascript split method and join strings using the replace characters with the join method. JavaScript Symbol.
Find elsewhere
🌐
Delft Stack
delftstack.com › home › howto › javascript › javascript remove special characters
How to Remove Special Characters in JavaScript | Delft Stack
February 2, 2024 - In the above code, (^\&) removes the & symbol and , (comma) for removing , from the string.
🌐
Code Beautify
codebeautify.org › blog › remove-special-sharacters-from-string-javascript
Remove Special Characters From String Javascript
February 22, 2024 - Approach 1 : 1 2 3 4 5 6 7 8 9 10 11 function removeSpecialCharacters(inputString) { // Use a regular expression to match and replace special characters return inputString.replace(/[^\w\s]/gi, ''); } // Example usage: const originalString = "Hello!
🌐
TutorialsPoint
tutorialspoint.com › article › javascript-regex-how-to-replace-special-characters
JavaScript regex - How to replace special characters?
The JavaScript built-in method string.replace() can be used to replace a portion of a supplied string with another string or a regular expression.
🌐
RSWP Themes
rswpthemes.com › home › javascript tutorial › how to remove spaces and special characters from a string in javascript
How to Remove Spaces and Special Characters from a String in JavaScript
June 3, 2025 - How to remove spaces and special characters in JavaScript? Use the replace() method with a regular expression (regex) to remove spaces and special characters.
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-remove-special-characters-from-string
Remove special Characters from a String in JavaScript | bobbyhadz
Last updated: Mar 1, 2024 Reading time·3 min · Use the replace() method to remove all special characters from a string, e.g. str.replace(/[^a-zA-Z0-9 ]/g, '');
🌐
TutorialsPoint
tutorialspoint.com › home › articles on trending technologies › write a regular expression to remove all special characters from a javascript string?
Write a Regular Expression to remove all special characters from a JavaScript String?
June 23, 2020 - Learn how to write a regular expression to remove all special characters from a JavaScript string effectively. This guide provides step-by-step instructions and examples.
🌐
Metring
ricardometring.com › javascript-replace-special-characters
JavaScript: Replacing Special Characters - The Clean Way
const replaceSpecialChars = (str) => { return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '') // Remove accents .replace(/([^\w]+|\s+)/g, '-') // Replace space and other characters by hyphen .replace(/\-\-+/g, '-') // Replaces multiple hyphens by one hyphen .replace(/(^-+|-+$)/g, ''); // Remove extra hyphens from beginning or end of the string } console.log(replaceSpecialChars('This is a sentence!!!'));
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-remove-all-characters-except-numbres
Remove all non-numeric characters from String in JavaScript | bobbyhadz
If you want to leave dots in the result to try to preserve floating-point numbers, use the following regular expression. ... Copied!const str = 'bobby 123 !@#$%^hadz?.456_com'; const result = str.replace(/[^\d.]/g, ''); console.log(result); // 👉️ 123.456 ... The forward slashes / / mark the beginning and end of the regular expression. The part between the square brackets [] is called a character class and matches everything except for digits and dots.