Literal dot

2 snippets in Regular Expressions

RXRegular Expressions

Escaping Special Characters

RX · Basic Patterns
syntax
\. \* \+ \? \( \) \[ \] \{ \} \^ \$ \| \\
example
JS:  'Price: $9.99'.match(/\$\d+\.\d{2}/)
Py:  re.search(r'\$\d+\.\d{2}', 'Price: $9.99')
output
"$9.99"

Note All special regex characters must be escaped with a backslash to match literally. The special characters are: . * + ? ( ) [ ] { } ^ $ | \. In Python raw strings (r'...'), you only escape for regex, not for Python itself.

Dot Inside Character Class

RX · Character Classes
syntax
[.]  matches a literal period (no escaping needed)
example
JS:  'v2.1.0'.match(/[.]/g)
Py:  re.findall(r'[.]', '192.168.0.1')
output
JS: [".", "."]
Py: [".", ".", "."]

Note Inside a character class, the dot loses its special meaning and matches a literal period. Both [.] and \. work for matching periods, but [.] can be more readable.