fixes
This commit is contained in:
parent
876674fc37
commit
a0853ed30a
2 changed files with 6 additions and 9 deletions
|
@ -92,10 +92,7 @@ JavaScript is the only browser technology that combines these three things.
|
|||
|
||||
That's what makes JavaScript unique. That's why it's the most widespread tool for creating browser interfaces.
|
||||
|
||||
Moreover, frameworks like react native and ionic lets us develop mobile applications using JavaScript.
|
||||
|
||||
While planning to learn a new technology, it's beneficial to check its perspectives. So let's move on to the modern trends affecting it, including new languages and browser abilities.
|
||||
|
||||
That said, JavaScript also allows to create servers, mobile applications, etc.
|
||||
|
||||
## Languages "over" JavaScript
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
A number is `pattern:\d+`.
|
||||
The regexp for an integer number is `pattern:\d+`.
|
||||
|
||||
We can exclude negatives by prepending it with the negative lookahead: `pattern:(?<!-)\d+`.
|
||||
|
||||
If we try it now, we may notice one more "extra" result:
|
||||
Although, if we try it now, we may notice one more "extra" result:
|
||||
|
||||
```js run
|
||||
let reg = /(?<!-)\d+/g;
|
||||
|
@ -13,11 +13,11 @@ let str = "0 12 -5 123 -18";
|
|||
console.log( str.match(reg) ); // 0, 12, 123, *!*8*/!*
|
||||
```
|
||||
|
||||
It matches `match:8` of `subject:-18`. To exclude it, we need to ensure that the regexp starts matching a number not from the middle of another number.
|
||||
As you can see, it matches `match:8`, from `subject:-18`. To exclude it, we need to ensure that the regexp starts matching a number not from the middle of another (non-matching) number.
|
||||
|
||||
We can do it by specifying another negative lookbehind: `pattern:(?<!-)(?<!\d)\d+`. Now `pattern:(?<!\d)` ensures that a match does not start after another digit.
|
||||
We can do it by specifying another negative lookbehind: `pattern:(?<!-)(?<!\d)\d+`. Now `pattern:(?<!\d)` ensures that a match does not start after another digit, just what we need.
|
||||
|
||||
Or we can use a single lookbehind here:
|
||||
We can also join them into a single lookbehind here:
|
||||
|
||||
```js run
|
||||
let reg = /(?<![-\d])\d+/g;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue