regexp task

This commit is contained in:
Ilya Kantor 2019-07-24 11:58:06 +03:00
parent 03560a7f03
commit 5e8edafbe1
6 changed files with 43 additions and 31 deletions

View file

@ -0,0 +1,11 @@
A positive number with an optional decimal part is (per previous task): `pattern:\d+(\.\d+)?`.
Let's add an optional `-` in the beginning:
```js run
let reg = /-?\d+(\.\d+)?/g;
let str = "-1.5 0 2 -123.4.";
alert( str.match(reg) ); // -1.5, 0, 2, -123.4
```