I’m using the following reg ex to strip numbers from a string however it also removes the (-) from negative numbers. Does anyone know of a reg ex thats leaves the numbers as well as (-). Thanks.
var string = "jdhjhjcdhj-200";
alert(string.replace(/[^\d]/g,""));
Simply add
-in your regex:It gives you
-200