You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Above regular expression can accepts the strings `john_doe`, `jo-hn\_doe` and `john12\_as`. It does not match `Jo` because that string
22
+
Above regular expression can accept the strings `john_doe`, `jo-hn\_doe` and `john12\_as`. It does not match `Jo` because that string
23
23
contains uppercase letter and also it is too short.
24
24
25
25
## Table of Contents
@@ -41,7 +41,7 @@ contains uppercase letter and also it is too short.
41
41
-[Caret](#281-caret)
42
42
-[Dollar](#282-dollar)
43
43
-[Shorthand Character Sets](#3-shorthand-character-sets)
44
-
-[Lookaround](#4-ookaround)
44
+
-[Lookaround](#4-lookaround)
45
45
-[Positive Lookahead](#41-positive-lookahead)
46
46
-[Negative Lookahead](#42-negative-lookahead)
47
47
-[Positive Lookbehind](#43-positive-lookbehind)
@@ -110,10 +110,17 @@ expression `[Tt]he` means: an uppercase `T` or lowercase `t`, followed by the le
110
110
"[Tt]he" => <ahref="#learn-regex"><strong>The</strong></a> car parked in <ahref="#learn-regex"><strong>the</strong></a> garage.
111
111
</pre>
112
112
113
+
<<<<<<< HEAD
113
114
Just like above example the regular expression `ge[.]` means: a lowercase character `g`, followed by letter `e`, followed by `.` character.
114
115
115
116
<pre>
116
117
"ge[.]" => The car parked in the gara<ahref="#learn-regex"><strong>ge.</strong></a>
118
+
=======
119
+
A period inside a character set, however, means a literal period. The regular expression `ar[.]` means: a lowercase character `a`, followed by letter `r`, followed by a period.
120
+
121
+
<pre>
122
+
"ar[.]" => A garage is a good place to park a c<ahref="#learn-regex"><strong>ar.</strong></a>
123
+
>>>>>>> 7cac291415345a24a7bf1db02b6612576aab0446
117
124
</pre>
118
125
119
126
### 2.2.1 Negated character set
@@ -139,7 +146,7 @@ of preceding lowercase character `a`. But if it appears after a character set or
139
146
character set. For example the regular expression `[a-z]*` means: any number of lowercase letters in a row.
The `*` symbol can be used with the meta character `.` to match any string of characters `.*`. The `*` symbol can be used with the
@@ -180,7 +187,7 @@ character can be repeated. For example the regular expression `[0-9]{2,3}` means
180
187
characters in the range of 0 to 9).
181
188
182
189
<pre>
183
-
"[0-9]{2}" => The number was 9.<ahref="#learn-regex"><strong>999</strong></a>7 but we rounded it off to <ahref="#learn-regex"><strong>10</strong></a>.0.
190
+
"[0-9]{2,3}" => The number was 9.<ahref="#learn-regex"><strong>999</strong></a>7 but we rounded it off to <ahref="#learn-regex"><strong>10</strong></a>.0.
184
191
</pre>
185
192
186
193
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
@@ -232,7 +239,7 @@ expression `(f|c|m)at\.?` means: lowercase letter `f`, `c` or `m`, followed by l
232
239
233
240
## 2.8 Anchors
234
241
235
-
In regular expression to check if the matching symbol is the starting symbol or endnig symbol of the input string for this purpose
242
+
In regular expression to check if the matching symbol is the starting symbol or ending symbol of the input string for this purpose
236
243
we use anchors. Anchors are of two types: First type is Caret `^` that check if the matching character is the start character of the
237
244
input and the second type is Dollar `$` that checks if matching character is the last character of the input string.
238
245
@@ -342,7 +349,7 @@ are after not after the word `The` or `the`.
342
349
343
350
## 5. Flags
344
351
345
-
Flags are also called modifiers because they modifies the output of a regular expression. These flags can be used in any order or
352
+
Flags are also called modifiers because they modify the output of a regular expression. These flags can be used in any order or
346
353
combination, and are an integral part of the RegExp.
347
354
348
355
|Flag|Description|
@@ -387,9 +394,9 @@ string.
387
394
### 5.3 Multiline
388
395
389
396
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 fo the input string. But if we want that anchors works on each line we use `m` flag. For example the
397
+
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
391
398
regular expression `/at(.)?$/gm` means: lowercase character `a`, followed by lowercase character `t`, optionally anything except new
392
-
line. And beacause of `m` flag now regular expression engine matches pattern at the end of each line in a string.
399
+
line. And because of `m` flag now regular expression engine matches pattern at the end of each line in a string.
393
400
394
401
<pre>
395
402
"/.at(.)?$/" => The fat
@@ -407,15 +414,15 @@ line. And beacause of `m` flag now regular expression engine matches pattern at
407
414
408
415
**Positive Integers*: `^\d+$`
409
416
**Negative Integers*: `^-\d+$`
410
-
**Phone Number*: `^+?[\d\s]{3,}$`
411
-
**Phone with code*: `^+?[\d\s]+(?[\d\s]{10,}$`
417
+
**US Phone Number*: `^+?[\d\s]{3,}$`
418
+
**US Phone with code*: `^+?[\d\s]+(?[\d\s]{10,}$`
412
419
**Integers*: `^-?\d+$`
413
420
**Username*: `^[\w\d_.]{4,16}$`
414
421
**Alpha-numeric characters*: `^[a-zA-Z0-9]*$`
415
422
**Alpha-numeric characters with spaces*: `^[a-zA-Z0-9 ]*$`
0 commit comments