From 656700966b297ddf5edc8e208d4edfc350514dc5 Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Wed, 9 Dec 2020 01:45:06 +0200 Subject: [PATCH] Fix typos in 9.10 (Greedy and lazy quantifiers) --- .../4-find-html-tags-greedy-lazy/task.md | 2 +- .../10-regexp-greedy-and-lazy/article.md | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/9-regular-expressions/10-regexp-greedy-and-lazy/4-find-html-tags-greedy-lazy/task.md b/9-regular-expressions/10-regexp-greedy-and-lazy/4-find-html-tags-greedy-lazy/task.md index 8e96c921..6759152f 100644 --- a/9-regular-expressions/10-regexp-greedy-and-lazy/4-find-html-tags-greedy-lazy/task.md +++ b/9-regular-expressions/10-regexp-greedy-and-lazy/4-find-html-tags-greedy-lazy/task.md @@ -12,4 +12,4 @@ let str = '<> '; alert( str.match(regexp) ); // '', '', '' ``` -Here we assume that tag attributes may not contain `<` and `>` (inside squotes too), that simplifies things a bit. +Here we assume that tag attributes may not contain `<` and `>` (inside quotes too), that simplifies things a bit. diff --git a/9-regular-expressions/10-regexp-greedy-and-lazy/article.md b/9-regular-expressions/10-regexp-greedy-and-lazy/article.md index 79abc559..2f656479 100644 --- a/9-regular-expressions/10-regexp-greedy-and-lazy/article.md +++ b/9-regular-expressions/10-regexp-greedy-and-lazy/article.md @@ -88,7 +88,7 @@ These common words do not make it obvious why the regexp fails, so let's elabora That's probably not what we expected, but that's how it works. -**In the greedy mode (by default) a quantifier is repeated as many times as possible.** +**In the greedy mode (by default) a quantified character is repeated as many times as possible.** The regexp engine adds to the match as many characters as it can for `pattern:.+`, and then shortens that one by one, if the rest of the pattern doesn't match. @@ -109,7 +109,7 @@ let regexp = /".+?"/g; let str = 'a "witch" and her "broom" is one'; -alert( str.match(regexp) ); // witch, broom +alert( str.match(regexp) ); // "witch", "broom" ``` To clearly understand the change, let's trace the search step by step. @@ -179,7 +179,7 @@ let regexp = /"[^"]+"/g; let str = 'a "witch" and her "broom" is one'; -alert( str.match(regexp) ); // witch, broom +alert( str.match(regexp) ); // "witch", "broom" ``` The regexp `pattern:"[^"]+"` gives correct results, because it looks for a quote `pattern:'"'` followed by one or more non-quotes `pattern:[^"]`, and then the closing quote. @@ -293,9 +293,9 @@ alert( str2.match(regexp) ); // ,