Skip to content

Commit 4e5533b

Browse files
authored
Merge pull request #1094 from dyslexicon/master
Correct spelling
2 parents 46a9bb5 + 759ffd7 commit 4e5533b

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

9-regular-expressions/14-regexp-lookahead-lookbehind/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ The syntax is:
4040
- Positive lookbehind: `pattern:(?<=y)x`, matches `pattern:x`, but only if it follows after `pattern:y`.
4141
- Negative lookbehind: `pattern:(?<!y)x`, matches `pattern:x`, but only if there's no `pattern:y` before.
4242

43-
For example, let's change the price to US dollars. The dollar sign is usually before the number, so to look for `$30` we'll use `pattern:(?<=\$)\d+` -- an amount preceeded by `subject:$`:
43+
For example, let's change the price to US dollars. The dollar sign is usually before the number, so to look for `$30` we'll use `pattern:(?<=\$)\d+` -- an amount preceded by `subject:$`:
4444

4545
```js run
4646
let str = "1 turkey costs $30";
4747

4848
alert( str.match(/(?<=\$)\d+/) ); // 30 (skipped the sole number)
4949
```
5050

51-
And, to find the quantity -- a number, not preceeded by `subject:$`, we can use a negative lookbehind `pattern:(?<!\$)\d+`:
51+
And, to find the quantity -- a number, not preceded by `subject:$`, we can use a negative lookbehind `pattern:(?<!\$)\d+`:
5252

5353
```js run
5454
let str = "2 turkeys cost $60";

9-regular-expressions/15-regexp-infinite-backtracking-problem/article.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ First, one may notice that the regexp is a little bit strange. The quantifier `p
112112

113113
Indeed, the regexp is artificial. But the reason why it is slow is the same as those we saw above. So let's understand it, and then the previous example will become obvious.
114114

115-
What happen during the search of `pattern:(\d+)*$` in the line `subject:123456789z`?
115+
What happened during the search of `pattern:(\d+)*$` in the line `subject:123456789z`?
116116

117117
1. First, the regexp engine tries to find a number `pattern:\d+`. The plus `pattern:+` is greedy by default, so it consumes all digits:
118118

@@ -264,7 +264,9 @@ In other words:
264264
- The lookahead `pattern:?=` looks for the maximal count `pattern:a+` from the current position.
265265
- And then they are "consumed into the result" by the backreference `pattern:\1` (`pattern:\1` corresponds to the content of the second parentheses, that is `pattern:a+`).
266266

267-
There will be no backtracking, because lookahead does not backtrack. If it found like 5 times of `pattern:a+` and the further match failed, then it doesn't go back to 4.
267+
There will be no backtracking, because lookahead does not backtrack. If, for
268+
example, it found 5 instances of `pattern:a+` and the further match failed,
269+
it won't go back to the 4th instance.
268270

269271
```smart
270272
There's more about the relation between possessive quantifiers and lookahead in articles [Regex: Emulate Atomic Grouping (and Possessive Quantifiers) with LookAhead](http://instanceof.me/post/52245507631/regex-emulate-atomic-grouping-with-lookahead) and [Mimicking Atomic Groups](http://blog.stevenlevithan.com/archives/mimic-atomic-groups).

9-regular-expressions/20-regexp-unicode/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The unicode flag `/.../u` enables the correct support of surrogate pairs.
55

66
Surrogate pairs are explained in the chapter <info:string>.
77

8-
Let's briefly remind them here. In short, normally characters are encoded with 2 bytes. That gives us 65536 characters maximum. But there are more characters in the world.
8+
Let's briefly review them here. In short, normally characters are encoded with 2 bytes. That gives us 65536 characters maximum. But there are more characters in the world.
99

1010
So certain rare characters are encoded with 4 bytes, like `𝒳` (mathematical X) or `😄` (a smile).
1111

0 commit comments

Comments
 (0)