Skip to content Skip to sidebar Skip to footer

Javascript Regular Expression: Non-digit Character

How do I say remove a number preceded by a non-digit and followed by a dash, but leave the preceding non-digit character? RegExp: /[^\D]4\-/ String: http://localhost/images/4-6-.pn

Solution 1:

You want [\D] or [^\d], but not [^\D]. Regex is case-sensitive, \d matches a digit, and \D matches anything but a digit.


Post a Comment for "Javascript Regular Expression: Non-digit Character"