@@ -28,7 +28,7 @@ endif::interactive_target[]
2828Jamie)))(((evolution)))(((adoption)))(((integration)))Programming
2929((tool))s and techniques survive and spread in a chaotic, evolutionary
3030way. It's not always the pretty or brilliant ones that win but rather
31- the ones that function well enough within the right niche—for example
31+ the ones that function well enough within the right niche—for example,
3232by being integrated with another successful piece of technology.
3333
3434(((domain-specific language)))In this chapter, I will discuss one such
@@ -48,7 +48,7 @@ programmer.
4848
4949(((regular expression,creation)))(((RegExp constructor)))(((literal
5050expression)))(((slash character)))A regular expression is a type of
51- object. It can be either constructed with the `RegExp` constructor or
51+ object. It can either be constructed with the `RegExp` constructor or
5252written as a literal value by enclosing the pattern in forward slash
5353(`/`) characters.
5454
@@ -166,7 +166,7 @@ console.log(dateTime.test("30-jan-2003 15:20"));
166166----
167167
168168(((backslash character)))That looks completely awful, doesn't it? It has way too
169- many backslashes, producing a background noise that makes it hard to
169+ many backslashes, producing background noise that makes it hard to
170170spot the actual ((pattern)) expressed. We'll see a slightly improved
171171version of this expression
172172link:09_regexp.html#date_regexp_counted[later].
@@ -222,7 +222,7 @@ match zero instances if it can't find any suitable text to match.
222222
223223(((British English)))(((American English)))(((question mark)))A
224224question mark makes a part of a pattern “((optional))”, meaning it may
225- occur zero or one times . In the following example, the _u_ character
225+ occur zero or one time . In the following example, the _u_ character
226226is allowed to occur, but the pattern also matches when it is missing.
227227
228228[source,javascript]
@@ -260,7 +260,7 @@ braces)) by omitting the number on either side of the comma. So
260260
261261(((regular expression,grouping)))(((grouping)))To use an operator like `*` or
262262`+` on more than one element at a time, you can use ((parentheses)). A
263- part of a regular expression that is surrounded in parentheses counts
263+ part of a regular expression that is enclosed in parentheses counts
264264as a single element as far as the operators following it are
265265concerned.
266266
@@ -275,9 +275,9 @@ console.log(cartoonCrying.test("Boohoooohoohooo"));
275275second _o_ in _boo_ and _hoo_, respectively. The third `+` applies to
276276the whole group `(hoo+)`, matching one or more sequences like that.
277277
278- (((case- sensitivity)))(((capitalization)))(((regular
278+ (((case sensitivity)))(((capitalization)))(((regular
279279expression,flags)))The `i` at the end of the expression in the
280- previous example makes this regular expression case- insensitive, allowing it to
280+ previous example makes this regular expression case insensitive, allowing it to
281281match the uppercase _B_ in the input string, even though the pattern
282282is itself all lowercase.
283283
@@ -330,7 +330,7 @@ console.log(quotedText.exec("she said 'hello'"));
330330----
331331
332332(((capture group)))When a group does not end up being matched at all
333- (for example when followed by a question mark), its position in the
333+ (for example, when followed by a question mark), its position in the
334334output array will hold `undefined`. Similarly, when a group is matched
335335multiple times, only the last match ends up in the array.
336336
@@ -435,7 +435,7 @@ console.log(findDate("30-1-2003"));
435435(((matching)))(((regular expression,boundary)))Unfortunately,
436436`findDate` will also happily extract the nonsensical date 00-1-3000
437437from the string `"100-1-30000"`. A match may happen anywhere in the
438- string, so in this case it'll just start at the second character and
438+ string, so in this case, it'll just start at the second character and
439439end at the second-to-last character.
440440
441441(((boundary)))(((caret character)))(((dollar sign)))If we want to
@@ -524,7 +524,7 @@ our progress through the flow chart would look like this:
524524 do see “pig”, so we take that branch.
525525
526526 - At position 9, after the three-way branch, one path skips
527- the _s_ box and go straight to the final word boundary, while the other path
527+ the _s_ box and goes straight to the final word boundary, while the other path
528528 matches an _s_. There is an _s_ character here, not a word boundary,
529529 so we go through the _s_ box.
530530
@@ -585,12 +585,12 @@ of the string, the star operator tries to match one character less.
585585But the matcher doesn't find an _x_ after `abcx` either, so it
586586backtracks again, matching the star operator to just `abc`. _Now_ it
587587finds an _x_ where it needs it and reports a successful match from
588- position 0 to 4.
588+ positions 0 to 4.
589589
590590(((performance)))(((complexity)))It is possible to write regular
591591expressions that will do a _lot_ of backtracking. This problem occurs
592592when a pattern can match a piece of input in many different ways. For
593- example, if we get confused while writing a binary-number regexp , we
593+ example, if we get confused while writing a binary-number regular expression , we
594594might accidentally write something like `/([01]+)+b/`.
595595
596596image::img/re_slow.svg[alt="Visualization of /([01]+)+b/",width="6cm"]
@@ -620,7 +620,7 @@ console.log("papa".replace("p", "m"));
620620(((regular expression,flags)))(((regular expression,global)))The first
621621argument can also be a regular expression, in which case the first
622622match of the regular expression is replaced. When a `g` option (for
623- “global” ) is added to the regular expression, _all_ matches in the
623+ _global_ ) is added to the regular expression, _all_ matches in the
624624string will be replaced, not just the first.
625625
626626[source,javascript]
@@ -860,7 +860,7 @@ will start.
860860
861861(((interface,design)))(((exec method)))(((regular
862862expression,global)))Those circumstances are that the regular
863- expression must have the “ global” (`g`) option enabled, and the match
863+ expression must have the global (`g`) option enabled, and the match
864864must happen through the `exec` method. Again, a more sane solution
865865would have been to just allow an extra argument to be passed to
866866`exec`, but sanity is not a defining characteristic of JavaScript's
@@ -1025,7 +1025,7 @@ function parseINI(string) {
10251025
10261026(((parseINI function)))(((parsing)))This code goes over every line in
10271027the file, updating the “current section” object as it goes along.
1028- First it checks whether the line can be ignored, using the expression
1028+ First, it checks whether the line can be ignored, using the expression
10291029`/^\s*(;.*)?$/`. Do you see how it works? The part between the
10301030((parentheses)) will match comments, and the `?` will make sure it
10311031also matches lines containing only whitespace.
@@ -1078,8 +1078,8 @@ Unicode standard considers whitespace, including things like the
10781078((implementation))s in other programming languages have syntax to
10791079match specific ((Unicode)) character categories, such as “all
10801080uppercase letters”, “all punctuation”, or “control characters”. There
1081- are plans to add support for such categories JavaScript, but they
1082- unfortunately look like they won't be realized in the near ((future)).
1081+ are plans to add support for such categories JavaScript, but it
1082+ unfortunately looks like they won't be realized in the near ((future)).
10831083
10841084[[summary_regexp]]
10851085== Summary ==
@@ -1122,7 +1122,7 @@ pass a function to `replace`, which will be used to build up a
11221122replacement string based on the match text and matched groups.
11231123
11241124Regular expressions can have options, which are written after
1125- the closing slash. The `i` option makes the match case- insensitive,
1125+ the closing slash. The `i` option makes the match case insensitive,
11261126while the `g` option makes the expression _global_, which, among other
11271127things, causes the `replace` method to replace all instances instead
11281128of just the first.
@@ -1316,7 +1316,7 @@ separate the two cases—either one or more digits optionally followed
13161316by a dot and zero or more digits _or_ a dot followed by one or more
13171317digits.
13181318
1319- (((exponent)))(((case- sensitivity)))(((regular
1319+ (((exponent)))(((case sensitivity)))(((regular
13201320expression,flags)))Finally, to make the _e_ case-insensitive, either
13211321add an `i` option to the regular expression or use `[eE]`.
13221322
0 commit comments