Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

remove punctuation marks from string js

const regex = /[!"#$%&'()*+,-./:;<=>?@[]^_`{|}~]/g;
const result = WANTED_STRING.replace(regex, '');
Comment

remove all the punctuations in javascript

If you want to remove specific punctuation from a string, it will probably be best to explicitly remove exactly what you want like

replace(/[.,/#!$%^&*;:{}=-_`~()]/g,"")
Doing the above still doesn't return the string as you have specified it. If you want to remove any extra spaces that were left over from removing crazy punctuation, then you are going to want to do something like

replace(/s{2,}/g," ");
Comment

PREVIOUS NEXT
Code Example
Javascript :: Consider using the "jsdom" test environment. 
Javascript :: generate random whole numbers within a range javascript 
Javascript :: javascript remove quotes from string 
Javascript :: Uncaught TypeError: firebase_app__WEBPACK_IMPORTED_MODULE_4__.default.storage is not a function 
Javascript :: javascript sleep for 1 second 
Javascript :: js find object length 
Javascript :: electronjs start with devtools enabled 
Javascript :: regex pattern for positive numbers only 
Javascript :: is string javascript 
Javascript :: counterup cdn 
Javascript :: bootstrap modal title center 
Javascript :: ajax beforesend 
Javascript :: jquery submit form via ajax 
Javascript :: js if not undefined 
Javascript :: run a function after delay javascript 
Javascript :: how to edit the visibiility of an element javscript 
Javascript :: js object to querystring 
Javascript :: check ObjectId is valid in mongoose 
Javascript :: node write text to file 
Javascript :: updating node js ubuntu 
Javascript :: react.js installation 
Javascript :: bootstrap show modal jquery 
Javascript :: UnhandledPromiseRejectionWarning: MongoParseError: URI does not have hostname, domain name and tld 
Javascript :: javascript scroll to element 
Javascript :: npx for windows 
Javascript :: just number regex js 
Javascript :: brain.js cdn 
Javascript :: javascript biggest number 
Javascript :: disable console log alert eslint 
Javascript :: jquery if class exists 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =