Skip to content

Commit 276f48d

Browse files
authored
Fix typos in 9.13 (Alternation (OR) |)
1 parent 633db6f commit 276f48d

File tree

1 file changed

+3
-3
lines changed
  • 9-regular-expressions/13-regexp-alternation

1 file changed

+3
-3
lines changed

9-regular-expressions/13-regexp-alternation/article.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ alert( str.match(regexp) ); // 'HTML', 'CSS', 'JavaScript'
2020

2121
We already saw a similar thing -- square brackets. They allow to choose between multiple characters, for instance `pattern:gr[ae]y` matches `match:gray` or `match:grey`.
2222

23-
Square brackets allow only characters or character sets. Alternation allows any expressions. A regexp `pattern:A|B|C` means one of expressions `A`, `B` or `C`.
23+
Square brackets allow only characters or character classes. Alternation allows any expressions. A regexp `pattern:A|B|C` means one of expressions `A`, `B` or `C`.
2424

2525
For instance:
2626

@@ -33,7 +33,7 @@ To apply alternation to a chosen part of the pattern, we can enclose it in paren
3333

3434
## Example: regexp for time
3535

36-
In previous articles there was a task to build a regexp for searching time in the form `hh:mm`, for instance `12:00`. But a simple `pattern:\d\d:\d\d` is too vague. It accepts `25:99` as the time (as 99 seconds match the pattern, but that time is invalid).
36+
In previous articles there was a task to build a regexp for searching time in the form `hh:mm`, for instance `12:00`. But a simple `pattern:\d\d:\d\d` is too vague. It accepts `25:99` as the time (as 99 minutes match the pattern, but that time is invalid).
3737

3838
How can we make a better pattern?
3939

@@ -47,7 +47,7 @@ We can write both variants in a regexp using alternation: `pattern:[01]\d|2[0-3]
4747

4848
Next, minutes must be from `00` to `59`. In the regular expression language that can be written as `pattern:[0-5]\d`: the first digit `0-5`, and then any digit.
4949

50-
If we glue minutes and seconds together, we get the pattern: `pattern:[01]\d|2[0-3]:[0-5]\d`.
50+
If we glue hours and minutes together, we get the pattern: `pattern:[01]\d|2[0-3]:[0-5]\d`.
5151

5252
We're almost done, but there's a problem. The alternation `pattern:|` now happens to be between `pattern:[01]\d` and `pattern:2[0-3]:[0-5]\d`.
5353

0 commit comments

Comments
 (0)