Skip to content

Commit 766f124

Browse files
bperelziishaned
authored andcommitted
Fix typos and syntax (ziishaned#19)
1 parent 8af2fe0 commit 766f124

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

README.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ contains uppercase letter and also it is too short.
5454

5555
## 1. Basic Matchers
5656

57-
A regular expression is just a pattern of letters and digits that we use to perform search in a text. For example the regular expression
57+
A regular expression is just a pattern of letters and digits that we use to perform search in a text. For example, the regular expression
5858
`cat` means: the letter `c`, followed by the letter `a`, followed by the letter `t`.
5959

6060
<pre>
@@ -93,7 +93,7 @@ The meta characters are as follows:
9393
## 2.1 Full stop
9494

9595
Full stop `.` is the simplest example of meta character. The meta character `.` matches any single character. It will not match return
96-
or new line characters. For example the regular expression `.ar` means: any character, followed by the letter `a`, followed by the
96+
or new line characters. For example, the regular expression `.ar` means: any character, followed by the letter `a`, followed by the
9797
letter `r`.
9898

9999
<pre>
@@ -102,8 +102,8 @@ letter `r`.
102102

103103
## 2.2 Character set
104104

105-
Character sets are also called character class. Square brackets are used to specify character sets. Use hyphen inside character set to
106-
specify the characters range. The order of the character range inside square brackets doesn't matter. For example the regular
105+
Character sets are also called character class. Square brackets are used to specify character sets. Use a hyphen inside a character set to
106+
specify the characters' range. The order of the character range inside square brackets doesn't matter. For example, the regular
107107
expression `[Tt]he` means: an uppercase `T` or lowercase `t`, followed by the letter `h`, followed by the letter `e`.
108108

109109
<pre>
@@ -118,8 +118,8 @@ A period inside a character set, however, means a literal period. The regular ex
118118

119119
### 2.2.1 Negated character set
120120

121-
In general the caret symbol represents the start of the string, but when it is typed after the opening square bracket it negates the
122-
character set. For example the regular expression `[^c]ar` means: any character except `c`, followed by the character `a`, followed by
121+
In general, the caret symbol represents the start of the string, but when it is typed after the opening square bracket it negates the
122+
character set. For example, the regular expression `[^c]ar` means: any character except `c`, followed by the character `a`, followed by
123123
the letter `r`.
124124

125125
<pre>
@@ -136,14 +136,14 @@ differently in different situations.
136136

137137
The symbol `*` matches zero or more repetitions of the preceding matcher. The regular expression `a*` means: zero or more repetitions
138138
of preceding lowercase character `a`. But if it appears after a character set or class that it finds the repetitions of the whole
139-
character set. For example the regular expression `[a-z]*` means: any number of lowercase letters in a row.
139+
character set. For example, the regular expression `[a-z]*` means: any number of lowercase letters in a row.
140140

141141
<pre>
142142
"[a-z]*" => T<a href="#learn-regex"><strong>he</strong></a> <a href="#learn-regex"><strong>car</strong></a> <a href="#learn-regex"><strong>parked</strong></a> <a href="#learn-regex"><strong>in</strong></a> <a href="#learn-regex"><strong>the</strong></a> <a href="#learn-regex"><strong>garage</strong></a> #21.
143143
</pre>
144144

145145
The `*` symbol can be used with the meta character `.` to match any string of characters `.*`. The `*` symbol can be used with the
146-
whitespace character `\s` to match a string of whitespace characters. For example the expression `\s*cat\s*` means: zero or more
146+
whitespace character `\s` to match a string of whitespace characters. For example, the expression `\s*cat\s*` means: zero or more
147147
spaces, followed by lowercase character `c`, followed by lowercase character `a`, followed by lowercase character `t`, followed by
148148
zero or more spaces.
149149

@@ -153,7 +153,7 @@ zero or more spaces.
153153

154154
### 2.3.2 The Plus
155155

156-
The symbol `+` matches one or more repetitions of the preceding character. For example the regular expression `c.+t` means: lowercase
156+
The symbol `+` matches one or more repetitions of the preceding character. For example, the regular expression `c.+t` means: lowercase
157157
letter `c`, followed by any number of character, followed by the lowercase character `t`.
158158

159159
<pre>
@@ -163,7 +163,7 @@ letter `c`, followed by any number of character, followed by the lowercase chara
163163
### 2.3.3 The Question Mark
164164

165165
In regular expression the meta character `?` makes the preceding character optional. This symbol matches zero or one instance of
166-
the preceding character. For example the regular expression `[T]?he` means: Optional the uppercase letter `T`, followed by the lowercase
166+
the preceding character. For example, the regular expression `[T]?he` means: Optional the uppercase letter `T`, followed by the lowercase
167167
character `h`, followed by the lowercase character `e`.
168168

169169
<pre>
@@ -176,14 +176,14 @@ character `h`, followed by the lowercase character `e`.
176176
## 2.4 Braces
177177

178178
In regular expression braces that are also called quantifiers are used to specify the number of times that a
179-
character or a group of characters can be repeated. For example the regular expression `[0-9]{2,3}` means: Match at least 2 digits but not more than 3 (
179+
character or a group of characters can be repeated. For example, the regular expression `[0-9]{2,3}` means: Match at least 2 digits but not more than 3 (
180180
characters in the range of 0 to 9).
181181

182182
<pre>
183183
"[0-9]{2,3}" => The number was 9.<a href="#learn-regex"><strong>999</strong></a>7 but we rounded it off to <a href="#learn-regex"><strong>10</strong></a>.0.
184184
</pre>
185185

186-
We can leave out the second number. For example the regular expression `[0-9]{2,}` means: Match 2 or more digits. If we also remove
186+
We can leave out the second number. For example, the regular expression `[0-9]{2,}` means: Match 2 or more digits. If we also remove
187187
the comma the regular expression `[0-9]{2}` means: Match exactly 2 digits.
188188

189189
<pre>
@@ -198,8 +198,8 @@ the comma the regular expression `[0-9]{2}` means: Match exactly 2 digits.
198198

199199
Character group is a group of sub-pattern that is written inside Parentheses `(...)`. As we discussed before that in regular expression
200200
if we put a quantifier after a character than it will repeat the preceding character. But if we put quantifier after a character group then
201-
it repeats the whole character group. For example the regular expression `(ab)*` matches zero or more repetitions of the character "ab".
202-
We can also use the alternation `|` meta character inside character group. For example the regular expression `(c|g|p)ar` means: lowercase character `c`,
201+
it repeats the whole character group. For example, the regular expression `(ab)*` matches zero or more repetitions of the character "ab".
202+
We can also use the alternation `|` meta character inside character group. For example, the regular expression `(c|g|p)ar` means: lowercase character `c`,
203203
`g` or `p`, followed by character `a`, followed by character `r`.
204204

205205
<pre>
@@ -209,8 +209,8 @@ We can also use the alternation `|` meta character inside character group. For e
209209
## 2.6 Alternation
210210

211211
In regular expression Vertical bar `|` is used to define alternation. Alternation is like a condition between multiple expressions. Now,
212-
you maybe thinking that character set and alternation works the same way. But the big difference between character set and alternation
213-
is that character set works on character level but alternation works on expression level. For example the regular expression
212+
you may be thinking that character set and alternation works the same way. But the big difference between character set and alternation
213+
is that character set works on character level but alternation works on expression level. For example, the regular expression
214214
`(T|t)he|car` means: uppercase character `T` or lowercase `t`, followed by lowercase character `h`, followed by lowercase character `e`
215215
or lowercase character `c`, followed by lowercase character `a`, followed by lowercase character `r`.
216216

@@ -222,7 +222,7 @@ or lowercase character `c`, followed by lowercase character `a`, followed by low
222222

223223
Backslash `\` is used in regular expression to escape the next character. This allows to to specify a symbol as a matching character
224224
including reserved characters `{ } [ ] / \ + * . $ ^ | ?`. To use a special character as a matching character prepend `\` before it.
225-
For example the regular expression `.` is used to match any character except new line. Now to match `.` in an input string the regular
225+
For example, the regular expression `.` is used to match any character except new line. Now to match `.` in an input string the regular
226226
expression `(f|c|m)at\.?` means: lowercase letter `f`, `c` or `m`, followed by lowercase character `a`, followed by lowercase letter
227227
`t`, followed by optional `.` character.
228228

@@ -254,7 +254,7 @@ followed by lowercase character `h`, followed by lowercase character `e`.
254254

255255
### 2.8.2 Dollar
256256

257-
Dollar `$` symbol is used to check if matching character is the last character of the input string. For example regular expression
257+
Dollar `$` symbol is used to check if matching character is the last character of the input string. For example, regular expression
258258
`(at\.)$` means: a lowercase character `a`, followed by lowercase character `t`, followed by a `.` character and the matcher
259259
must be end of the string.
260260

@@ -285,7 +285,7 @@ regular expressions. The shorthand character sets are as follows:
285285

286286
Lookbehind and lookahead sometimes known as lookaround are specific type of ***non-capturing group*** (Use to match the pattern but not
287287
included in matching list). Lookaheads are used when we have the condition that this pattern is preceded or followed by another certain
288-
pattern. For example we want to get all numbers that are preceded by `$` character from the following input string `$4.44 and $10.88`.
288+
pattern. For example, we want to get all numbers that are preceded by `$` character from the following input string `$4.44 and $10.88`.
289289
We will use following regular expression `(?<=\$)[0-9\.]*` which means: get all the numbers which contains `.` character and preceded
290290
by `$` character. Following are the lookarounds that are used in regular expressions:
291291

@@ -301,7 +301,7 @@ by `$` character. Following are the lookarounds that are used in regular express
301301
The positive lookahead asserts that the first part of the expression must be followed by the lookahead expression. The returned match
302302
only contains the text that is matched by the first part of the expression. To define a positive lookahead braces are used and within
303303
those braces question mark with equal sign is used like this `(?=...)`. Lookahead expression is written after the equal sign inside
304-
braces. For example the regular expression `(T|t)he(?=\sfat)` means: optionally match lowercase letter `t` or uppercase letter `T`,
304+
braces. For example, the regular expression `(T|t)he(?=\sfat)` means: optionally match lowercase letter `t` or uppercase letter `T`,
305305
followed by letter `h`, followed by letter `e`. In braces we define positive lookahead which tells regular expression engine to match
306306
`The` or `the` which are followed by the word `fat`.
307307

@@ -323,7 +323,7 @@ input string that are not followed by the word `fat` precedes by a space charact
323323
### 4.3 Positive Lookbehind
324324

325325
Positive lookbehind is used to get all the matches that are preceded by a specific pattern. Positive lookbehind is denoted by
326-
`(?<=...)`. For example the regular expression `(?<=(T|t)he\s)(fat|mat)` means: get all `fat` or `mat` words from input string that
326+
`(?<=...)`. For example, the regular expression `(?<=(T|t)he\s)(fat|mat)` means: get all `fat` or `mat` words from input string that
327327
are after the word `The` or `the`.
328328

329329
<pre>
@@ -333,8 +333,8 @@ are after the word `The` or `the`.
333333
### 4.4 Negative Lookbehind
334334

335335
Negative lookbehind is used to get all the matches that are not preceded by a specific pattern. Negative lookbehind is denoted by
336-
`(?<!...)`. For example the regular expression `(?&lt;!(T|t)he\s)(cat)` means: get all `cat` words from input string that
337-
are after not after the word `The` or `the`.
336+
`(?<!...)`. For example, the regular expression `(?&lt;!(T|t)he\s)(cat)` means: get all `cat` words from input string that
337+
are not after the word `The` or `the`.
338338

339339
<pre>
340340
"(?&lt;!(T|t)he\s)(cat)" => The cat sat on <a href="#learn-regex"><strong>cat</strong></a>.
@@ -353,7 +353,7 @@ combination, and are an integral part of the RegExp.
353353

354354
### 5.1 Case Insensitive
355355

356-
The `i` modifier is used to perform case-insensitive matching. For example the regular expression `/The/gi` means: uppercase letter
356+
The `i` modifier is used to perform case-insensitive matching. For example, the regular expression `/The/gi` means: uppercase letter
357357
`T`, followed by lowercase character `h`, followed by character `e`. And at the end of regular expression the `i` flag tells the
358358
regular expression engine to ignore the case. As you can see we also provided `g` flag because we want to search for the pattern in
359359
the whole input string.
@@ -369,7 +369,7 @@ the whole input string.
369369
### 5.2 Global search
370370

371371

372-
The `g` modifier is used to perform a global match (find all matches rather than stopping after the first match). For example the
372+
The `g` modifier is used to perform a global match (find all matches rather than stopping after the first match). For example, the
373373
regular expression`/.(at)/g` means: any character except new line, followed by lowercase character `a`, followed by lowercase
374374
character `t`. Because we provided `g` flag at the end of the regular expression now it will find every matches from whole input
375375
string.
@@ -386,8 +386,8 @@ string.
386386

387387
### 5.3 Multiline
388388

389-
The `m` modifier is used to perform a multi line match. As we discussed earlier anchors `(^, $)` are used to check if pattern is
390-
the beginning of the input or end of the input string. But if we want that anchors works on each line we use `m` flag. For example the
389+
The `m` modifier is used to perform a multi-line match. As we discussed earlier anchors `(^, $)` are used to check if pattern is
390+
the beginning of the input or end of the input string. But if we want that anchors works on each line we use `m` flag. For example, the
391391
regular expression `/at(.)?$/gm` means: lowercase character `a`, followed by lowercase character `t`, optionally anything except new
392392
line. And because of `m` flag now regular expression engine matches pattern at the end of each line in a string.
393393

0 commit comments

Comments
 (0)