Skip to content

Commit 63301d6

Browse files
committed
Add escaping special character
1 parent 000dd57 commit 63301d6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ contains uppercase letter and also it is too short.
3030
- [The Question Mark]()
3131
- [Character Group]()
3232
- [Alternation]()
33+
- [Escaping special character]()
3334
- [Quantifiers]()
3435
- [OR operator]()
3536
- [Character Sets]()
@@ -202,4 +203,16 @@ or lowercase character `c`, followed by lowercase character `a`, followed by low
202203

203204
<pre>
204205
"[T|t]he|car" => <a href="#learn-regex"><strong>The</strong></a> <a href="#learn-regex"><strong>car</strong></a> is parked in <a href="#learn-regex"><strong>the</strong></a> garage.
206+
</pre>
207+
208+
## 2.6 Escaping special character
209+
210+
Backslash `\` is used in regular expression to escape the next character. This allows to to specify a symbol as a matching character
211+
including reserved characters `{ } [ ] / \ + * . $ ^ | ?`. To use a special character as a matching character prepend `\` before it.
212+
For example the regular expression `.` is used to match any character except new line. Now to match `.` in an input string the regular
213+
expression `[f|c|m]at\.?` means: lowercase letter `f`, `c` or `m`, followed by lowercase character `a`, followed by lowercase letter
214+
`t`, followed by optional `.` character.
215+
216+
<pre>
217+
"[f|c|m]at\.?" => The <a href="#learn-regex"><strong>fat</strong></a> <a href="#learn-regex"><strong>cat</strong></a> sat on the <a href="#learn-regex"><strong>mat.</strong></a>
205218
</pre>

0 commit comments

Comments
 (0)