Create a regexp to match numbers. It should find positive numbers: both integer and numbers with the decimal point:
var re = /* your regexp */ var str = "1.5 0 123" alert(str.match(re)) // '1.5', '0', '123'
Решение
Решение
An integer number is \d+.
A decimal part is \.\d+, and we can make it optional with '?'.
Finally, we have \d+(\.\d+)?:
var re = /\d+(\.\d+)?/g var str = "1.5 0 123" alert(str.match(re)) // '1.5', '0', '123'
#262