From 5ba5f8b79b001a278392a6eef458394f321badde Mon Sep 17 00:00:00 2001 From: duianto Date: Wed, 21 Nov 2018 15:23:38 +0100 Subject: [PATCH 1/2] Add a missing 0 --- .../09-regexp-groups/1-find-webcolor-3-or-6/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5-regular-expressions/09-regexp-groups/1-find-webcolor-3-or-6/task.md b/5-regular-expressions/09-regexp-groups/1-find-webcolor-3-or-6/task.md index 3078a757..4efd6f61 100644 --- a/5-regular-expressions/09-regexp-groups/1-find-webcolor-3-or-6/task.md +++ b/5-regular-expressions/09-regexp-groups/1-find-webcolor-3-or-6/task.md @@ -8,7 +8,7 @@ let reg = /your regexp/g; let str = "color: #3f3; background-color: #AA00ef; and: #abcd"; -alert( str.match(reg) ); // #3f3 #AA0ef +alert( str.match(reg) ); // #3f3 #AA00ef ``` P.S. This should be exactly 3 or 6 hex digits: values like `#abcd` should not match. From 219e9dbbc519314d24916692dcb4c6fc4b1b10e6 Mon Sep 17 00:00:00 2001 From: duianto Date: Wed, 21 Nov 2018 15:56:26 +0100 Subject: [PATCH 2/2] Add missing 0s and an 'a', remove double spaces --- .../09-regexp-groups/1-find-webcolor-3-or-6/solution.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/5-regular-expressions/09-regexp-groups/1-find-webcolor-3-or-6/solution.md b/5-regular-expressions/09-regexp-groups/1-find-webcolor-3-or-6/solution.md index 443fdd85..d653ff97 100644 --- a/5-regular-expressions/09-regexp-groups/1-find-webcolor-3-or-6/solution.md +++ b/5-regular-expressions/09-regexp-groups/1-find-webcolor-3-or-6/solution.md @@ -6,7 +6,7 @@ The simplest way to add them -- is to append to the regexp: `pattern:/#[a-f0-9]{ We can do it in a smarter way though: `pattern:/#([a-f0-9]{3}){1,2}/i`. -Here the regexp `pattern:[a-f0-9]{3}` is in parentheses to apply the quantifier `pattern:{1,2}` to it as a whole. +Here the regexp `pattern:[a-f0-9]{3}` is in parentheses to apply the quantifier `pattern:{1,2}` to it as a whole. In action: @@ -15,15 +15,15 @@ let reg = /#([a-f0-9]{3}){1,2}/gi; let str = "color: #3f3; background-color: #AA00ef; and: #abcd"; -alert( str.match(reg) ); // #3f3 #AA0ef #abc +alert( str.match(reg) ); // #3f3 #AA00ef #abc ``` -There's minor problem here: the pattern found `match:#abc` in `subject:#abcd`. To prevent that we can add `pattern:\b` to the end: +There's a minor problem here: the pattern found `match:#abc` in `subject:#abcd`. To prevent that we can add `pattern:\b` to the end: ```js run let reg = /#([a-f0-9]{3}){1,2}\b/gi; let str = "color: #3f3; background-color: #AA00ef; and: #abcd"; -alert( str.match(reg) ); // #3f3 #AA0ef +alert( str.match(reg) ); // #3f3 #AA00ef ```