πŸ‡―πŸ‡΅ζ—₯本θͺž

Regex Tester

Test regular expressions with match highlighting, capture group display, and real-time replacement preview.

Runs entirely in your browser β€” no data is sent to any server

Pattern

//

Test Text

About the Regex Tester

Regular expressions (regex) are a powerful pattern-matching syntax used for validation, log parsing, text transformation, and more. This tool uses the browser's standard RegExp API directly, so any JavaScript-compatible regular expression can be tested here without server roundtrips. Enter a pattern, paste your test text, and matching portions are highlighted in real time.

Regex Flags

The g (global) flag finds all matches in the string rather than stopping at the first. The i (case-insensitive) flag makes letter-matching ignore case differences. The m (multiline) flag changes the behavior of ^ and $ so they anchor to the start and end of each line, not just the whole string. The s (dotAll) flag makes the dot . match newline characters, which is useful for matching content that spans multiple lines such as HTML tags or multiline JSON values. Flags can be combined: gi matches all occurrences case-insensitively.

Capture Groups and Named Groups

Parentheses in a pattern define a capture group. For example, (\d{4})-(\d{2})-(\d{2}) captures the year, month, and day as groups 1, 2, and 3 respectively. This tool displays the captured values for each match below the full match string. Named groups use the syntax (?<name>...) β€” for instance, (?<year>\d{4}) β€” and can be referenced as $<year> in replacements or accessed as match.groups.year in JavaScript. Named groups are recommended for complex patterns because they make the regex self-documenting.

Replacement Syntax

The Replace panel shows a real-time preview of the text after substitution. In the replacement string, $1, $2, etc. reference numbered capture groups (e.g., replace (\d{4})-(\d{2})-(\d{2}) with $2/$3/$1 to reformat dates from YYYY-MM-DD to MM/DD/YYYY). $& refers to the entire match, $` refers to the text before the match, and $' refers to text after the match. Named groups can be referenced with $<name>. Click 'Copy result' to copy the substituted text to your clipboard.