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 :: text inside image react native 
Javascript :: classes in js 
Javascript :: var vs let javascript 
Javascript :: array methods in javascript 
Javascript :: how to scroll automatically to the bottom of the page using javascript 
Javascript :: moment now 
Javascript :: append javascript variable to html 
Javascript :: password validation in javascript 
Javascript :: Access to localhost from other machine - Angular 
Javascript :: regex javscript 
Javascript :: date.setdate javascript 
Javascript :: electron Uncaught ReferenceError: require is not defined 
Javascript :: usecontext multiple provider 
Javascript :: run function periodically with setInterval 
Javascript :: open in new tab js html does not work on iphone 
Javascript :: regex concatenazione 
Javascript :: selectize in ajax call 
Javascript :: javascript rest parameter 
Javascript :: fetch second parameters 
Javascript :: javascript best practices 
Javascript :: React ES6 Variables 
Javascript :: Photoshop extendscript javascript save to text file a list of layers 
Javascript :: how to send the captured image from js to python backedn flask 
Javascript :: phaser place items on circle 
Javascript :: phaser pause animation instances 
Javascript :: reactjs doc error 
Javascript :: check notification permissopn allow or not 
Javascript :: sadd in redis 
Javascript :: × error: element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. you likely forgot to export your component from the file it 
Javascript :: js index of 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =