This commit is contained in:
Ilya Kantor 2017-05-25 11:56:32 +03:00
parent 787d58a83f
commit 455d300d8d
280 changed files with 2 additions and 2 deletions

View file

@ -0,0 +1,16 @@
An integer number is `pattern:\d+`.
A decimal part is: `pattern:\.\d+`.
Because the decimal part is optional, let's put it in parentheses with quantifier `pattern:'?'`.
Finally we have the regexp: `pattern:\d+(\.\d+)?`:
```js run
let reg = /\d+(\.\d+)?/g;
let str = "1.5 0 12. 123.4.";
alert( str.match(re) ); // 1.5, 0, 12, 123.4
```