Merge pull request #2375 from vsemozhetbyt/patch-7

Correct example in 9.14 (Lookahead and lookbehind)
This commit is contained in:
Ilya Kantor 2020-12-13 20:23:33 +03:00 committed by GitHub
commit 093dfe4c6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,7 +54,7 @@ The syntax is: `pattern:X(?!Y)`, it means "search `pattern:X`, but only if not f
```js run
let str = "2 turkeys cost 60€";
alert( str.match(/\d+(?!€)/) ); // 2 (the price is skipped)
alert( str.match(/\d+\b(?!€)/g) ); // 2 (the price is not matched)
```
## Lookbehind
@ -81,7 +81,7 @@ And, if we need the quantity -- a number, not preceded by `subject:$`, then we c
```js run
let str = "2 turkeys cost $60";
alert( str.match(/(?<!\$)\d+/) ); // 2 (skipped the price)
alert( str.match(/(?<!\$)\b\d+/g) ); // 2 (the price is not matched)
```
## Capturing groups