From 6fc5b2c55526ea1fd5fb1f13dea47beb89d8470a Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Wed, 9 Dec 2020 22:37:29 +0200 Subject: [PATCH] Correct example in 9.14 (Lookahead and lookbehind) Without the `g` flag, we cannot say that the price is skipped. Without the `\b` assertion, we will have the part of the price in the result. --- .../14-regexp-lookahead-lookbehind/article.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/9-regular-expressions/14-regexp-lookahead-lookbehind/article.md b/9-regular-expressions/14-regexp-lookahead-lookbehind/article.md index 48c82da1..9f4f4f6c 100644 --- a/9-regular-expressions/14-regexp-lookahead-lookbehind/article.md +++ b/9-regular-expressions/14-regexp-lookahead-lookbehind/article.md @@ -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(/(?