Skip to content

Commit 08a08f7

Browse files
authored
Merge pull request #628 from duianto/patch-1
Add a missing 0
2 parents f9bec9f + 219e9db commit 08a08f7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

5-regular-expressions/09-regexp-groups/1-find-webcolor-3-or-6/solution.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The simplest way to add them -- is to append to the regexp: `pattern:/#[a-f0-9]{
66

77
We can do it in a smarter way though: `pattern:/#([a-f0-9]{3}){1,2}/i`.
88

9-
Here the regexp `pattern:[a-f0-9]{3}` is in parentheses to apply the quantifier `pattern:{1,2}` to it as a whole.
9+
Here the regexp `pattern:[a-f0-9]{3}` is in parentheses to apply the quantifier `pattern:{1,2}` to it as a whole.
1010

1111
In action:
1212

@@ -15,15 +15,15 @@ let reg = /#([a-f0-9]{3}){1,2}/gi;
1515

1616
let str = "color: #3f3; background-color: #AA00ef; and: #abcd";
1717

18-
alert( str.match(reg) ); // #3f3 #AA0ef #abc
18+
alert( str.match(reg) ); // #3f3 #AA00ef #abc
1919
```
2020

21-
There's minor problem here: the pattern found `match:#abc` in `subject:#abcd`. To prevent that we can add `pattern:\b` to the end:
21+
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:
2222

2323
```js run
2424
let reg = /#([a-f0-9]{3}){1,2}\b/gi;
2525

2626
let str = "color: #3f3; background-color: #AA00ef; and: #abcd";
2727

28-
alert( str.match(reg) ); // #3f3 #AA0ef
28+
alert( str.match(reg) ); // #3f3 #AA00ef
2929
```

5-regular-expressions/09-regexp-groups/1-find-webcolor-3-or-6/task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let reg = /your regexp/g;
88

99
let str = "color: #3f3; background-color: #AA00ef; and: #abcd";
1010

11-
alert( str.match(reg) ); // #3f3 #AA0ef
11+
alert( str.match(reg) ); // #3f3 #AA00ef
1212
```
1313

1414
P.S. This should be exactly 3 or 6 hex digits: values like `#abcd` should not match.

0 commit comments

Comments
 (0)