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 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

filter 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 :: react native scrollview in modal 
Javascript :: express server template 
Javascript :: javascript array insert at 0 
Javascript :: drupal 8 render node programmatically 
Javascript :: REMOVING EMPTY ARRAY INDEX 
Javascript :: calculate time difference in hrs moment 
Javascript :: string array to number array javascript 
Javascript :: javascript json string 
Javascript :: how to change the color using js 
Javascript :: javascript array find highest value of array of objects by key 
Javascript :: add value to the top of an array in js 
Javascript :: How to include JSPs file from another folder 
Javascript :: angular declare variable in a file 
Javascript :: Ready check failed: NOAUTH Authentication required. 
Javascript :: node readline question 
Javascript :: js sort string array 
Javascript :: Making font weight bold by passing value in React.js 
Javascript :: mongoose connect to URL of atlas 
Javascript :: option selected jquery 
Javascript :: redirect link javascript 
Javascript :: change form action js 
Javascript :: nodejs express api 
Javascript :: javascript regex escape forward slash 
Javascript :: javascript interview preparation 
Javascript :: Express’s default X-Powered-By header Disabling 
Javascript :: fs.readdir example 
Javascript :: jquery observe class change 
Javascript :: js not equal to null 
Javascript :: how to extract year from utc in javascript 
Javascript :: printf statement in javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =