I'm trying to get a regex working that will replace everything except for numbers and a decimal point (easy). The tricky part: the decimal point is optional but, if present, must be trailed by a further number.
So:
.10 => 10
10. => 10
10.- => 10
1.0 => 1.0
I'm not quite sure how 开发者_JS百科to define the "except numbers followed by an optional decimal point but mandatory number after the optional decimal point" bit :)
Thanks!
It would be something like this:
\d+(\.\d+)?
(Please note that the regex syntax you are using may require different escaping.)
精彩评论