Skip to content

Commit 3c37e1d

Browse files
committed
fixes #1041
1 parent 6a4c419 commit 3c37e1d

File tree

2 files changed

+13
-5
lines changed
  • 1-js/02-first-steps/03-strict-mode
  • 9-regular-expressions/10-regexp-backreferences

2 files changed

+13
-5
lines changed

1-js/02-first-steps/03-strict-mode/article.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,17 @@ For the future, when you use a browser console to test features, please note tha
5353
5454
Sometimes, when `use strict` makes a difference, you'll get incorrect results.
5555
56-
Even if we press `key:Shift+Enter` to input multiple lines, and put `use strict` on top, it doesn't work. That's because of how the console executes the code internally.
56+
You can try to press `key:Shift+Enter` to input multiple lines, and put `use strict` on top, like this:
5757
58-
The reliable way to ensure `use strict` would be to input the code into console like this:
58+
```js
59+
'use strict'; <Shift+Enter for a newline>
60+
// ...your code
61+
<Enter to run>
62+
```
63+
64+
It works in most browsers, namely Firefox and Chrome.
65+
66+
If it doesn't, the most reliable way to ensure `use strict` would be to input the code into console like this:
5967

6068
```js
6169
(function() {

9-regular-expressions/10-regexp-backreferences/article.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Backreferences in pattern: \n and \k
22

3-
Capturing groups can be accessed not only in the result or in the replacement string, but also in the pattern itself.
3+
We can use the contents of capturing groups `(...)` not only in the result or in the replacement string, but also in the pattern itself.
44

55
## Backreference by number: \n
66

@@ -12,7 +12,7 @@ We need to find a quoted string: either a single-quoted `subject:'...'` or a dou
1212

1313
How to look for them?
1414

15-
We can put two kinds of quotes in the pattern: `pattern:['"](.*?)['"]`, but it would find strings with mixed quotes, like `match:"...'` and `match:'..."`. That would lead to incorrect matches when one quote appears inside other ones, like the string `subject:"She's the one!"`:
15+
We can put both kinds of quotes in the square brackets: `pattern:['"](.*?)['"]`, but it would find strings with mixed quotes, like `match:"...'` and `match:'..."`. That would lead to incorrect matches when one quote appears inside other ones, like the string `subject:"She's the one!"`:
1616

1717
```js run
1818
let str = `He said: "She's the one!".`;
@@ -25,7 +25,7 @@ alert( str.match(reg) ); // "She'
2525

2626
As we can see, the pattern found an opening quote `match:"`, then the text is consumed lazily till the other quote `match:'`, that closes the match.
2727

28-
To make sure that the pattern looks for the closing quote exactly the same as the opening one, we can make a groups of it and use the backreference.
28+
To make sure that the pattern looks for the closing quote exactly the same as the opening one, we can wrap it into a capturing group and use the backreference.
2929

3030
Here's the correct code:
3131

0 commit comments

Comments
 (0)