You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Группы скобок нумируются слева направо. Поисковый движок запоминает содержимое в каждой группе и позволяет ссылаться на него в шаблоне регулярного выражения или строке для замены.
51
51
52
-
For instance, we'd like to find HTML tags`pattern:<.*?>`, and process them.
52
+
Например, мы хотим найти HTML теги`pattern:<.*?>` и обрадотать их.
53
53
54
-
Let's wrap the inner content into parentheses, like this: `pattern:<(.*?)>`.
54
+
Давайте заключим внутреннее содержимое в круглые скобки: `pattern:<(.*?)>`.
55
55
56
-
We'll get them into an array:
56
+
Соберем их в массив:
57
57
58
58
```js run
59
59
let str ='<h1>Hello, world!</h1>';
@@ -62,14 +62,14 @@ let reg = /<(.*?)>/;
62
62
alert( str.match(reg) ); // Array: ["<h1>", "h1"]
63
63
```
64
64
65
-
The call to [String#match](mdn:js/String/match)returns groups only if the regexp has no `pattern:/.../g` flag.
65
+
Вызов [String#match](mdn:js/String/match)возвращает группы только если регулярное выражение не имеет флаг `pattern:/.../g`.
66
66
67
-
If we need all matches with their groups then we can use `.matchAll`or`regexp.exec`as described in<info:regexp-methods>:
67
+
Если необходимы все совпадения с их группировкой, то мы можем использовать `.matchAll`или`regexp.exec`как описано в<info:regexp-methods>:
68
68
69
69
```js run
70
70
let str ='<h1>Hello, world!</h1>';
71
71
72
-
//two matches: opening <h1> and closing </h1> tags
72
+
//два совпадения: теги открытия <h1> и закрытия </h1>
0 commit comments