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, ""));
More Related Contents:
- Remove all special characters with RegExp
- Get Character value from KeyCode in JavaScript… then trim
- How to ignore acute accent in a javascript regex match?
- avoid to escape a special characters in javascript
- How to detect line breaks in a text area input?
- jQuery: Check if special characters exists in string
- How to add function in JSX?
- Javascript does not work
- How do I format a date in JavaScript?
- How do I check if an object has a specific property in JavaScript?
- jQuery click / toggle between two functions
- Force browser to download image files on click
- Doesn’t JavaScript support closures with local variables? [duplicate]
- jQuery: load txt file and insert into div
- Array Like Objects in Javascript
- Getting mouse location in canvas [duplicate]
- How to detect right mouse click + paste using JavaScript?
- Perform .join on value in array of objects
- Why is 4 not an instance of Number?
- jQuery index() in vanilla javascript
- Call two functions from same onclick [duplicate]
- Rxjs One Observable Feeding into Another
- Is “Put Scripts at the Bottom” Correct? [closed]
- JavaScript only being called once in Squarespace
- Dynamically adding cases to a switch
- How to use React.forwardRef in a class based component?
- Take User Back to Where They Scrolled to on previous page when clicking Browser Back Button
- window.open() simply adds the url to my current url
- Does MongoDB have a native REST interface?
- Browser: Uncaught ReferenceError: require is not defined