Find positive numbers
Create a regexp that looks for positive numbers, including those without a decimal point.
An example of use:
let reg = /your regexp/g; let str = "1.5 0 -5 12. 123.4."; alert( str.match(reg) ); // 1.5, 12, 123.4 (ignores 0 and -5)
An non-negative integer number is
\d+. We should exclude
0 as the first digit, as we don’t need zero, but we can allow it in further digits.
So that gives us
A decimal part is:
Because the decimal part is optional, let’s put it in parentheses with the quantifier
Finally we have the regexp: