Add html tags

This commit is contained in:
Zeeshan Ahmed 2017-07-23 06:21:16 +01:00
parent 6e224071cc
commit 5d3f9b41b3

View File

@ -17,13 +17,14 @@ from a string based upon a pattern match, and so much more.
8. [Lookaheads]()
9. [Flags]()
# 1. Basic Matchers
## 1. Basic Matchers
A regular expression is just a pattern of letters and digits that we used to search in a text. For example the
regular expression `cat` means: the letter `c`, followed by the letter `a`, followed by the letter `t`.
<pre>
"cat" => The <strong>cat</strong> sat on the mat
"cat" => The <strong><u>cat</u></strong> sat on the mat
</pre>
The regular expression `123` matches the string "123". The regular expression is matched against an input string
@ -31,10 +32,10 @@ by comparing each character in the regular expression to each character in the i
Regular expressions are normally case-sensitive so the regular expression `Cat` would not match the string "cat".
<pre>
"Cat" => The cat sat on the <strong>Cat</strong>
"Cat" => The cat sat on the <strong><u>Cat</u></strong>
</pre>
# 2. Meta Characters
## 2. Meta Characters
Meta characters are the building blocks of the regular expressions. Some meta characters have a special meaning
that are written inside the square brackets. The meta character are as follows:
@ -54,17 +55,17 @@ that are written inside the square brackets. The meta character are as follows:
|<b>^</b>|Matches the beginning of the input.|
|<b>$</b>|Matches the end of the input.|
# 2.1 Full stop
## 2.1 Full stop
Full stop `.` is the simplest example of meta character. The meta character `.` matches any single character. It
will not match return or new line characters. For example the regular expression `.ar` means: any character,
followed by the letter `a`, followed by the letter `r`.
<pre>
".ar" => The <strong>car</strong> <strong>par</strong>ked in the <strong>gar</strong>age.
".ar" => The <strong><u>car</u></strong> <strong><u>par</u></strong>ked in the <strong><u>gar</u></strong>age.
</pre>
# 2.2 Character set
## 2.2 Character set
Character sets are also called character class. Square brackets are used to specify character sets. Use hyphen
inside character set to specify the characters range. The order of the character range inside square brackets
@ -72,25 +73,25 @@ doesn't matter. For example the regular expression `[Tt]he` means: an uppercase
the letter `h`, followed by the letter `e`.
<pre>
"[Tt]he" => <strong>The</strong> car parked in <strong>the</strong> garage.
"[Tt]he" => <strong><u>The</u></strong> car parked in <strong><u>the</u></strong> garage.
</pre>
## 2.2.1 Negated character set
### 2.2.1 Negated character set
In general the caret symbol represents the start of the string, but when it is typed after the opening square
bracket it negates the character set. For example the regular expression `[^c]ar` means: any character except
`c`, followed by the character `a`, followed by the letter `r`.
<pre>
"[^c]ar" => The car <strong>par</strong>ked in the <strong>gar</strong>age.
"[^c]ar" => The car <strong><u>par</u></strong>ked in the <strong><u>gar</u></strong>age.
</pre>
## 2.2.2 Repeating character set
### 2.2.2 Repeating character set
We can repeat a character class by using `+`, `*` or `?` operators. For example the regular expression `[a-z]+`
means: any number of lowercase letters in a row.
<pre>
"[a-z]+" => <strong>The</strong> <strong>car</strong> <strong>parked</strong> <strong>in</strong> <strong>the</strong> <strong>garage</strong>.
"[a-z]+" => <strong><u>The</u></strong> <strong><u>car</u></strong> <strong><u>parked</u></strong> <strong><u>in</u></strong> <strong><u>the</u></strong> <strong><u>garage</u></strong>.
</pre>