Skip to content

Commit 219e9db

Browse files
authored
Add missing 0s and an 'a', remove double spaces
1 parent 5ba5f8b commit 219e9db

File tree

1 file changed

+4
-4
lines changed
  • 5-regular-expressions/09-regexp-groups/1-find-webcolor-3-or-6

1 file changed

+4
-4
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
```

0 commit comments

Comments
 (0)