Skip to content

Commit efb2159

Browse files
authored
Update solution.md
1 parent 5514fae commit efb2159

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

  • 9-regular-expressions/09-regexp-groups/1-find-webcolor-3-or-6

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
A regexp to search 3-digit color `#abc`: `pattern:/#[a-f0-9]{3}/i`.
1+
Регэксп для поиска номера цвета из трех символов `#abc`: `pattern:/#[a-f0-9]{3}/i`.
22

3-
We can add exactly 3 more optional hex digits. We don't need more or less. Either we have them or we don't.
3+
Мы можем добавить точно 3 дополнительные шестнадцатеричные цифры. Нам не нужно больше или меньше. Либо у нас они есть, либо у нас нет.
44

5-
The simplest way to add them -- is to append to the regexp: `pattern:/#[a-f0-9]{3}([a-f0-9]{3})?/i`
5+
Простейший способ добавить их -- добавить в регулярное выражение: `pattern:/#[a-f0-9]{3}([a-f0-9]{3})?/i`
66

7-
We can do it in a smarter way though: `pattern:/#([a-f0-9]{3}){1,2}/i`.
7+
Мы можем сделать это более интересным способом: `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+
Этот регэксп `pattern:[a-f0-9]{3}` в скобках для применения квантификатора `pattern:{1,2}` к нему вцелом.
1010

11-
In action:
11+
В действии:
1212

1313
```js run
1414
let reg = /#([a-f0-9]{3}){1,2}/gi;
@@ -18,7 +18,7 @@ let str = "color: #3f3; background-color: #AA00ef; and: #abcd";
1818
alert( str.match(reg) ); // #3f3 #AA00ef #abc
1919
```
2020

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:
21+
Здесь есть небольшая проблема: шаблон находит `match: # abc` в` subject: # abcd`. Чтобы предотвратить это, мы можем добавить `pattern: \ b` в конец:
2222

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

0 commit comments

Comments
 (0)