javascript regex optional minus
问题 I have the following function in javascript: function unString(String){ var justNumbers = /(?=.*\d)\d*(?:\.\d*)?/; var result = String.match(justNumbers); result *= 1; result = Math.round(result*100) / 100; return result; } The meaning of it is to extract the number out of every possible css value, so that it can be added or substracted or multiplied with other values: e. g. var newPadding = unString( $('#myID').css("padding-bottom") )*10 + "px"; Having modified my code I would now need the