This commit is contained in:
Ilya Kantor 2017-03-19 20:40:47 +03:00
parent 75e30539ef
commit 62c507c78f
92 changed files with 583 additions and 574 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
```

View file

@ -0,0 +1,13 @@
# Find all numbers
Write a regexp that looks for all decimal numbers including integer ones, with the floating point and negative ones.
An example of use:
```js
let reg = /your regexp/g;
let str = "-1.5 0 2 -123.4.";
alert( str.match(re) ); // -1.5, 0, 2, -123.4
```