Regex Tester

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.

/ /
Flags:

Highlighted Matches

Highlighted matches will appear here...
0 matches
Enter a regex pattern to see matches

Common Patterns

Regex Quick Reference

How It Works

Real-Time Testing

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.

🎨

Color-Coded Matches

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.

🔍

Capture Groups

View numbered and named capture groups for every match. Perfect for debugging complex patterns with multiple groups and backreferences.

🔄

Replace Mode

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.

Understanding Regular Expressions

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.

How to Use This Tool

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.

Common Use Cases

Frequently Asked Questions

What is a regular expression?
A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. It is used for pattern matching within strings -- finding, replacing, or validating text. Regular expressions are supported in virtually every programming language (JavaScript, Python, Java, Go, etc.) as well as text editors (VS Code, Sublime Text) and command-line tools (grep, sed, awk). The syntax uses special characters like . (any character), * (zero or more), + (one or more), [] (character class), and () (capture group) to build powerful search patterns.
What are regex flags and when should I use them?
Flags modify how the regex engine processes a pattern. The most common flags are: 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.
What are capture groups and how do I use them?
Capture groups are portions of a regex pattern enclosed in parentheses (). 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.
How does the replace mode work?
Enable replace mode with the toggle to show the replacement input field. Enter a replacement string and the tool will show you the result of applying regex replacement to your test string in real time. You can use special replacement patterns: $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.
Is my data safe? Does anything get sent to a server?
Your data is completely safe. This regex tester runs entirely in your browser using JavaScript. No data -- not your regex pattern, test string, or results -- is ever sent to any server, stored in any database, or logged anywhere. Everything is processed locally on your device. You can verify this by opening your browser's developer tools and checking the Network tab while using the tool. This makes it safe to test patterns against sensitive data like log files, configuration strings, or any other private text.
Why is my regex not matching what I expect?
Common reasons regex patterns do not match as expected include: forgetting to enable the 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.

Explore More Developer Tools

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 →