Skip to content

Commit 57a804d

Browse files
committed
use strict
1 parent ad41cb8 commit 57a804d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

10-regular-expressions-javascript/7-regexp-groups/article.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
```js
1818
//+ run
19-
alert( 'Gogogo now!'.match(/(go)+/i ); // "Gogogo"
19+
alert( 'Gogogo now!'.match(/(go)+/i) ); // "Gogogo"
2020
```
2121

2222
Без скобок, шаблон <code class="pattern">/go+/</code> означал бы <code class="subject">g</code>, после которого идёт одна или более <code class="subject">o</code>, например: <code class="match">goooo</code>. А скобки "группируют" <code class="pattern">(go)</code> вместе.
@@ -77,7 +77,7 @@ while ((match = reg.exec(str)) !== null) {
7777
//+ run
7878
var str = '<span class="my">';
7979

80-
reg = /<(([a-z]+)\s*([^>]*))>/;
80+
var reg = /<(([a-z]+)\s*([^>]*))>/;
8181

8282
alert( str.match(reg) ); // <span class="my">, span, s
8383
```
@@ -98,7 +98,7 @@ alert( str.match(reg) ); // <span class="my">, span, s
9898

9999
```js
100100
//+ run
101-
match = 'a'.match(/a(z)?(c)?/)
101+
var match = 'a'.match(/a(z)?(c)?/)
102102

103103
alert( match.length ); // 3
104104
alert( match[0] ); // a
@@ -112,7 +112,7 @@ alert( match[2] ); // undefined
112112

113113
```js
114114
//+ run
115-
match = 'ack'.match(/a(z)?(c)?/)
115+
var match = 'ack'.match(/a(z)?(c)?/)
116116

117117
alert( match.length ); // 3
118118
alert( match[0] ); // ac, всё совпадение

10-regular-expressions-javascript/8-regexp-backreferences/article.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ alert( name ); // Пушкин, Александр
3636

3737
```js
3838
//+ run
39-
str = "He said: \"She's the one!\".";
39+
var str = "He said: \"She's the one!\".";
4040

41-
reg = /['"](.*?)['"]/g;
41+
var reg = /['"](.*?)['"]/g;
4242

4343
// Результат не соответствует замыслу
4444
alert( str.match(reg) ); // "She'
@@ -50,9 +50,9 @@ alert( str.match(reg) ); // "She'
5050

5151
```js
5252
//+ run
53-
str = "He said: \"She's the one!\".";
53+
var str = "He said: \"She's the one!\".";
5454

55-
reg = /(['"])(.*?)\1/g;
55+
var reg = /(['"])(.*?)\1/g;
5656

5757
alert( str.match(reg) ); // "She's the one!"
5858
```

0 commit comments

Comments
 (0)