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 prevent context menu 
Javascript :: js vanilla dom ready 
Javascript :: npx react 
Javascript :: set time out js 
Javascript :: javascript audio stop 
Javascript :: page reload timeout 
Javascript :: random id js 
Javascript :: jest wait for x seconds 
Javascript :: js canvas triangle 
Javascript :: 50 50 chance javascript 
Javascript :: react-native text overflow ellipsis 
Javascript :: use application/x-www-form-urlencoded in javascript 
Javascript :: get height use js 
Javascript :: react toggle class 
Javascript :: go to page jquery 
Javascript :: express js clear cookie 
Javascript :: c# json get value by key 
Javascript :: javascript sort boolean value 
Javascript :: mouseover angular 6 
Javascript :: regular expression for links 
Javascript :: jquery open a new tab 
Javascript :: js reload page 1024 breakpoint 
Javascript :: jquery get form data 
Javascript :: node js quit 
Javascript :: moment today date 
Javascript :: passport.authenticate inside a controller 
Javascript :: × MUI: makeStyles is not longer exported from @mui/material/styles. You have to import it from @mui/styles. 
Javascript :: save on focus lost sublime 
Javascript :: window viewport size javascript 
Javascript :: vue settimeout in computed 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =