Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

remove special characters from string javascript

var str = "Hello^# World/";
str.replace(/[^a-zA-Z ]/g, ""); // "Hello World"
Comment

remove a special character from string javascript

//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, '');
Comment

remove special characters from string javascript

var desired = stringToReplace.replace(/[^ws]/gi, '')

//if you are using non english like arabic and other language
var outString = sourceString.replace(/[`~!@#$%^&*()_|+-=?;:'",.<>{}[]/]/gi, '');
Comment

remove special characters javascript

function filterCharacter(str) {
   // First set a mode
   let pattern = new RegExp(
      "[`~!@#$^&*()=:”“'。,、?|{}':;'%,[].<>/?~!@#$……&*()&;—|{ }【】‘;]"
   );
   let resultStr1 = '';
   for (let j = 0; j < str.length; j++) {
      // Mainly through replace, pattern rules to replace characters with empty and finally spliced in resultStr1
      resultStr1 = resultStr1 + str.substr(j, 1).replace(pattern, '');
   }
   // When the loop ends, return the final result resultStr1
   return resultStr1;
}

// Example
filterCharacter('gyaskjdhy12316789#$%^&!@#1=123,./['); // Result: gyaskjdhy123167891123
Comment

js remove special characters

var desired = stringToReplace.replace(/[^ws]/gi, '')
Comment

remove special characters in javascript

const str = "abc's test#s";
console.log(str.replace(/[^a-zA-Z ]/g, ""));
 Run code snippet
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript int to float 
Javascript :: replacing each space in a string javascript 
Javascript :: jquery ajax form submit 
Javascript :: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. 
Javascript :: local storage check if key exists 
Javascript :: add leading zeros to number javascript 
Javascript :: disable right click javascript 
Javascript :: how to use lodash in angular 
Javascript :: install node js in manjaro 
Javascript :: clear terminal node js 
Javascript :: javascript change meta tag 
Javascript :: jquery close bootstrap model 
Javascript :: Uncaught TypeError: $(...).select2 is not a function 
Javascript :: vscode debug ignore node_modules 
Javascript :: mui typography bold 
Javascript :: javascript float element right 
Javascript :: javascript get table row count 
Javascript :: puppeteer get html 
Javascript :: vue3 cdn 
Javascript :: text number of lines react native 
Javascript :: async iife 
Javascript :: Remove line breaks with JavaScript 
Javascript :: how to remove modal-backdrop fade in jquery 
Javascript :: socket io with cors 
Javascript :: getthe array length of jsonb object postgres 
Javascript :: aws secret manager nodejs javascript 
Javascript :: react native seperator code 
Javascript :: detecting screen width in jquery 
Javascript :: how to remove a class in js after 100 milliseconds 
Javascript :: stop immediate propagation 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =