Skip to content

Commit 8be5e09

Browse files
committed
Merge
2 parents 317c382 + 7cac291 commit 8be5e09

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

README.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<br/>
22
<p align="center">
3-
<img src="https://i.imgur.com/bYwl7Vf.png" alt="Logo">
3+
<img src="https://i.imgur.com/bYwl7Vf.png" alt="Learn Regex">
44
</p><br/>
55

66
## What is Regular Expression?
@@ -19,7 +19,7 @@ We use the following regular expression to validate a username:
1919
<img src="https://i.imgur.com/UrDb9qc.png" alt="Regular expression">
2020
</p>
2121

22-
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
2323
contains uppercase letter and also it is too short.
2424

2525
## Table of Contents
@@ -41,7 +41,7 @@ contains uppercase letter and also it is too short.
4141
- [Caret](#281-caret)
4242
- [Dollar](#282-dollar)
4343
- [Shorthand Character Sets](#3-shorthand-character-sets)
44-
- [Lookaround](#4-ookaround)
44+
- [Lookaround](#4-lookaround)
4545
- [Positive Lookahead](#41-positive-lookahead)
4646
- [Negative Lookahead](#42-negative-lookahead)
4747
- [Positive Lookbehind](#43-positive-lookbehind)
@@ -110,10 +110,17 @@ expression `[Tt]he` means: an uppercase `T` or lowercase `t`, followed by the le
110110
"[Tt]he" => <a href="#learn-regex"><strong>The</strong></a> car parked in <a href="#learn-regex"><strong>the</strong></a> garage.
111111
</pre>
112112

113+
<<<<<<< HEAD
113114
Just like above example the regular expression `ge[.]` means: a lowercase character `g`, followed by letter `e`, followed by `.` character.
114115

115116
<pre>
116117
"ge[.]" => The car parked in the gara<a href="#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<a href="#learn-regex"><strong>ar.</strong></a>
123+
>>>>>>> 7cac291415345a24a7bf1db02b6612576aab0446
117124
</pre>
118125

119126
### 2.2.1 Negated character set
@@ -139,7 +146,7 @@ of preceding lowercase character `a`. But if it appears after a character set or
139146
character set. For example the regular expression `[a-z]*` means: any number of lowercase letters in a row.
140147

141148
<pre>
142-
"[a-z]*" => <a href="#learn-regex"><strong>The</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.
149+
"[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.
143150
</pre>
144151

145152
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
180187
characters in the range of 0 to 9).
181188

182189
<pre>
183-
"[0-9]{2}" => 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.
190+
"[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.
184191
</pre>
185192

186193
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
232239

233240
## 2.8 Anchors
234241

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
236243
we use anchors. Anchors are of two types: First type is Caret `^` that check if the matching character is the start character of the
237244
input and the second type is Dollar `$` that checks if matching character is the last character of the input string.
238245

@@ -342,7 +349,7 @@ are after not after the word `The` or `the`.
342349

343350
## 5. Flags
344351

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
346353
combination, and are an integral part of the RegExp.
347354

348355
|Flag|Description|
@@ -387,9 +394,9 @@ string.
387394
### 5.3 Multiline
388395

389396
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
391398
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.
393400

394401
<pre>
395402
"/.at(.)?$/" => The fat
@@ -407,15 +414,15 @@ line. And beacause of `m` flag now regular expression engine matches pattern at
407414

408415
* *Positive Integers*: `^\d+$`
409416
* *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,}$`
412419
* *Integers*: `^-?\d+$`
413420
* *Username*: `^[\w\d_.]{4,16}$`
414421
* *Alpha-numeric characters*: `^[a-zA-Z0-9]*$`
415422
* *Alpha-numeric characters with spaces*: `^[a-zA-Z0-9 ]*$`
416423
* *Password*: `^(?=^.{6,}$)((?=.*[A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z]))^.*$`
417424
* *email*: `^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})*$`
418-
* *IP address*: `^((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))*$`
425+
* *IPv4 address*: `^((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))*$`
419426
* *Lowercase letters only*: `^([a-z])*$`
420427
* *Uppercase letters only*: `^([A-Z])*$`
421428
* *URL*: `^(((http|https|ftp):\/\/)?([[a-zA-Z0-9]\-\.])+(\.)([[a-zA-Z0-9]]){2,4}([[a-zA-Z0-9]\/+=%&_\.~?\-]*))*$`
@@ -433,4 +440,4 @@ line. And beacause of `m` flag now regular expression engine matches pattern at
433440

434441
## License
435442

436-
MIT © [Zeeshan Ahmed](mailto:[email protected])
443+
MIT © [Zeeshan Ahmed](mailto:[email protected])

0 commit comments

Comments
 (0)