Test and debug regular expressions in real time. See highlighted matches, capture groups, named groups, and replacement results -- all client-side. Your data never leaves your browser.
Type your regex pattern and test string and see matches highlighted instantly as you type. No need to press a button -- results update in real time with zero latency.
Each match is highlighted with a distinct color in the test string, making it easy to visually identify all matches at a glance. Match details show index positions and lengths.
View numbered and named capture groups for every match. Perfect for debugging complex patterns with multiple groups and backreferences.
Enable replace mode to test regex substitutions. Use $1, $2 for numbered groups or $<name> for named groups in your replacement string and see the result instantly.
Regular expressions (regex) are patterns used to match character combinations in strings. They are a powerful tool supported in virtually every programming language, text editor, and command-line tool. Regex is essential for tasks like input validation, text search and replacement, data extraction, and log parsing.
Enter your regex pattern in the pattern field and your test string in the text area below. The tool will instantly highlight all matches in the test string and show detailed information about each match, including index positions, lengths, and any capture groups. Use the flag checkboxes to control matching behavior, and try the preset buttons to quickly load common patterns.
. (any character), * (zero or more), + (one or more), [] (character class), and () (capture group) to build powerful search patterns.
g (global) -- find all matches instead of stopping after the first; i (case-insensitive) -- match uppercase and lowercase letters interchangeably; m (multiline) -- make ^ and $ match the start and end of each line instead of the whole string; s (dotAll) -- make . match newline characters as well; and u (unicode) -- enable full Unicode matching, which is important for patterns involving emoji or non-Latin characters. You can combine multiple flags, for example /pattern/gi for a global, case-insensitive search.
(). They "capture" the matched text so you can reference it later. Numbered groups are referenced by their position: $1 for the first group, $2 for the second, and so on. Named capture groups use the syntax (?<name>...) and can be referenced by name, e.g., $<name> in replacements. For example, the pattern (\d{4})-(\d{2})-(\d{2}) captures year, month, and day separately from a date string. Non-capturing groups (?:...) group without capturing, which is useful when you need grouping for alternation or quantifiers but do not need the matched text.
$1, $2, etc. to insert numbered capture groups; $<name> to insert named capture groups; $& to insert the entire match; $` for text before the match; and $' for text after the match. This is equivalent to JavaScript's String.prototype.replace() method with a regex.
g (global) flag when you want all matches; not escaping special characters like ., *, +, ?, (, ), [, ] with a backslash when you want to match them literally; greedy vs. lazy matching (use *? or +? for lazy matching); not accounting for newlines (enable the s flag to make . match newlines); and anchoring issues (use m flag if you want ^ and $ to match line boundaries). The highlighted output in this tool helps you visually debug what is actually being matched.
Check out our other free developer tools. Format JSON, decode JWTs, parse cron expressions, and more -- all from your browser with no sign-up required.
JSON Formatter →