Regex Basics

Literals, dots, and the core syntax every pattern builds on.

  • regex basics
  • regex dot
  • character class
  • alternation
  • regex group

Regex Basics

Literals, dots, and the core syntax every pattern builds on.

Commands

CommandWhat it does
abcLiteral match of abc
.Any character except newline
\d \w \sDigit, word char, whitespace
\D \W \SNegated classes
`ab`Alternation: a or b
(abc)Capturing group

Example

\d{4}-\d{2}-\d{2}   # date like 2026-10-11

FAQ

Do I need to escape dots in domains?

Yes - an unescaped dot matches anything, so write backslash-dot for literal dots in domains and IPs.

Which flavor should I learn first?

PCRE and JavaScript overlap most; always test in the target engine since lookbehind and unicode details differ.

FAQ

Do I need to escape dots in domains?
Yes - an unescaped dot matches anything, so write backslash-dot for literal dots in domains and IPs.
Which flavor should I learn first?
PCRE and JavaScript overlap most; always test in the target engine since lookbehind and unicode details differ.

Regex