Special Characters
Some characters have special meaning in regex. These are called metacharacters.
The Metacharacters
These characters are special in regex:
. ^ $ * + ? { } [ ] \ | ( )
To match them literally, you must escape them with a backslash \.
The Dot (.)
The dot matches any single character (except newline).
Notice c.t matches cat, cot, cut, c@t, c1t - but NOT cart (two characters between c and t).
Escaping Special Characters
To match a literal dot, use \.
Common Escapes
File Extensions
A practical example - matching file extensions:
Practice Playground
Try matching:
$19.99- escape $ and .@example- @ is not special(a*b)- escape parentheses and asterisk
Escape Reference
| Character | Escaped | Matches |
|---|---|---|
. | \. | Literal period |
$ | \$ | Literal dollar sign |
? | \? | Literal question mark |
* | \* | Literal asterisk |
+ | \+ | Literal plus sign |
( | \( | Literal parenthesis |
[ | \[ | Literal bracket |
\ | \\ | Literal backslash |
Key Takeaways
- The dot
.matches any single character - Metacharacters have special meaning
- Use backslash
\to escape special characters - When in doubt, escape it!

