Free Online Regex Tester
Type a regex pattern and see matches highlighted instantly in your test string
Try these next
Why use Regex Tester
- Uses the JavaScript RegExp engine, so the behavior here is identical to what your code will produce at runtime.
- Inline color highlighting shows what your pattern actually captures -- not what you think it captures.
- Captured groups and their indices appear in a separate table, which is essential for building parsers.
How it works
The tester constructs a new RegExp object from your pattern string and the selected flags on every input change. If the constructor throws a SyntaxError, the tool catches it and displays the engine's error message verbatim. When the regex is valid and the global flag is set, the tool calls matchAll() on the test string to produce an iterator of match objects, each containing the full match text, its index position, and an array of captured group values. Without the global flag, only exec() is called once. For the inline highlighting, the tool splits the test string at match boundaries and wraps matched segments in styled span elements with alternating background colors. Captured groups are displayed in a table beneath the matches, listing each group's index, name (if a named group was used), and captured text.
About this tool
Need to check whether your regex actually matches what you think it does? Type the pattern here, paste your test string, and watch matches highlight in real time. The tester uses JavaScript's native RegExp constructor, so the behavior is byte-for-byte identical to what your browser or Node.js code will produce. Lookaheads, lookbehinds, named capture groups, Unicode property escapes, and the dotAll flag all work exactly as they would in production. Every match shows its index position and captured groups in a separate table. When the global flag is set, matchAll() runs to find every match; without it, only exec() fires once. Invalid patterns surface the JavaScript engine's error message verbatim -- the same error your try/catch would get at runtime. This is faster than switching to a terminal to test grep patterns, and it gives visual feedback that a console can't: matched segments are color-highlighted inline so you can see at a glance whether your pattern is greedy where it should be lazy, or capturing more than it should.
How to use Regex Tester
- Type your regex pattern. Enter the regex into the Pattern field. Skip the surrounding / delimiters -- just the pattern itself (e.g. \d{3}-\d{4}).
- Set flags. Toggle g (global), i (case-insensitive), m (multiline), s (dotAll), or u (Unicode) depending on what you need.
- Paste your test string. Drop the text you want to match against. Matches highlight inline in real time with alternating colors.
- Review matches and groups. The panel below lists every match with its index and captured groups. Named groups show their names.
- Fix errors. If the pattern is invalid, the JavaScript engine's error message appears verbatim. Fix it, matches resume.
Use cases
- You're writing input validation for an email field and need to test the pattern against 15 edge cases -- valid addresses, malformed ones, internationalized domains. Paste them all, see what lights up.
- You've got a log parser with named capture groups for timestamp, log level, and message. Paste a few lines of Apache access log and confirm each group extracts what you expect.
- You've never used lookbehinds before. Type (?<=\$)\d+ and paste some text with dollar amounts to see which numbers match. Faster than reading the docs alone.
- A CI pipeline grep pattern is matching too broadly. Paste the test input here, see the greedy match, switch to lazy quantifiers, and verify before pushing the fix.
- You need to extract all href attributes from an HTML export. Test the pattern against a few lines to confirm it handles both single-quoted and double-quoted values.
Frequently Asked Questions
This tester uses JavaScript's built-in RegExp engine, which implements the ECMAScript regex specification. This means the patterns you test here will work identically in JavaScript, TypeScript, and Node.js code. Other languages (Python, Java, Ruby) have slightly different regex flavors -some features like lookbehinds or Unicode property escapes may behave differently.
g (global) finds all matches instead of stopping at the first. i (case-insensitive) matches regardless of letter case. m (multiline) makes ^ and $ match the start/end of each line instead of the whole string. s (dotAll) makes the . character match newlines too. u (unicode) enables full Unicode matching and makes quantifiers work correctly with astral characters like emoji.
Common issues: forgetting to enable the g flag (only finds the first match), not escaping special characters like . or * (they have special meaning in regex), using ^ or $ without the m flag when testing multiline input, or a typo in the pattern. Check the error message below the pattern input -it will tell you if your syntax is invalid.
Parentheses () in a regex create capturing groups that extract specific parts of a match. For example, the pattern (\d{3})-(\d{4}) matching '555-1234' captures '555' as group 1 and '1234' as group 2. Named groups use (?<name>...) syntax. This tool shows all captured groups in a separate table below the matches.
Greedy quantifiers (*, +, {n,}) match as much text as possible. Lazy quantifiers (*?, +?, {n,}?) match as little as possible. For example, given the text '<b>bold</b>', the greedy pattern <.*> matches the entire string, while the lazy pattern <.*?> matches only '<b>'. Use lazy matching when you want the shortest possible match.
Paste multiline text directly into the Test String field -it accepts newlines. Enable the m flag so ^ and $ match the start and end of each line rather than the entire string. Enable the g flag to find all matches across all lines. The s flag is needed if your pattern uses . to match across line boundaries.
Lookaheads and lookbehinds are zero-width assertions that match a position rather than consuming characters. A positive lookahead (?=...) asserts that the pattern ahead exists; (?!...) asserts it does not. A positive lookbehind (?<=...) asserts what came before; (?<!...) asserts it did not. For example, \d+(?= dollars) matches a number only when followed by ' dollars', without including ' dollars' in the match.
Related Tools
Discover more free utilities to enhance your productivity.