How To Negative Match Regex In JavaScript String Replace?
I am trying to replace with a blank all characters except numbers, but this doesn't works: s.replace(/(?!\d)/g, '') Thanks!
Solution 1:
Use negative character classes:
s.replace(/[^0-9]+/g, '')
or s.replace(/[^\d]+/g, '')
or s.replace(/\D+/g, '')
Post a Comment for "How To Negative Match Regex In JavaScript String Replace?"