What is Regular expression (regex)?

A regular expression is a pattern used to search for and replace text.

Patterns such as \d+ (one or more digits) or ^[A-Z]{5}[0-9]{4}[A-Z]$ describe the shape of text. Flags change behaviour: g finds all matches, i ignores case.

Test a pattern on sample text before using it in code, and be careful with patterns that can match very slowly on long input.

← All terms

↑ ↓ navigateEnter openEsc close