What is a regular expression?
A regular expression, usually shortened to regex, is a compact pattern for finding text. Regex is commonly used to validate input, extract values from logs, search source code, transform data, and enforce naming or formatting rules.
JavaScript regex patterns and flags
This tester uses your browser's JavaScript regular expression engine. Flags change how a pattern behaves: global finds every match, case-insensitive ignores letter case, multiline changes line anchors, dotAll lets a dot span newlines, Unicode enables Unicode-aware syntax, and sticky starts at the current search position.
Capture groups and replacements
Parentheses capture useful portions of a match for later inspection or replacement. A replacement string can reuse numbered groups such as $1 or named groups such as $<name>, which is useful for reformatting dates, identifiers, or structured text.
Test before using a regex in production
Try representative matches, non-matches, empty input, Unicode, and unusually long text. A pattern that works on one example can still be too broad, too narrow, or expensive on other input.