Regex tester — match highlighting and capture groups
Try a JavaScript regular expression on a short sample and see the matches, positions and captured values. Include text that should fail as well as text that should match before using the pattern in code.
Runs in your browser — your input is not uploaded to ToolsNow.
Quick reference
\ddigit 0–9\wASCII letter, digit or _\swhitespace.any character except a line break (unless s is on)*0 or more+1 or more?0 or 1{2,4}between 2 and 4^start$end[abc]one of a, b, c[^a]not a(…)capture group(?:…)group, no capturea|ba or b\bword boundaryThis uses your browser’s JavaScript regex engine. Other engines can handle groups, Unicode and lookbehind differently. The result list stops at 5,000 matches; complex patterns can still be slow to run.
How to use
- Enter Pattern. Leave off the surrounding slashes and flags. For example, use INV-(\d{4}) to find an invoice reference such as INV-0042.
- Set the flags. g collects all matches, i ignores case, m lets ^ and $ match line boundaries, and s lets . match a newline.
- Add a short Test text. Try valid references, incomplete ones and nearby text that should not match. Results update while you edit.
- Inspect and copy. Review Highlighted and Match details. Copy matches takes the matched text; Copy regex takes the pattern with its slashes and selected flags.
Questions
Will this pattern behave the same in my application?
It uses this browser’s JavaScript regex engine with g, i, m and s controls. There are no u, v, y or d controls here. Other runtimes and regex languages can differ, so check the pattern in your target environment, especially for lookbehind and Unicode features.
How do capture groups work?
Parentheses capture part of a match: INV-(\d{4}) captures 0042 from INV-0042 as $1. Use (?:…) to group without capturing, or (?<name>…) for a named group. When a pattern has named groups, the table shows those names instead of the numbered-group list.
What does the At column count?
It is the zero-based position in the JavaScript string. It counts UTF-16 code units, so an emoji before a match can add two positions even though it looks like one character.
Why are ^ and $ not matching each line?
Turn on m — ^ $ match lines. Without it, the anchors refer to the input’s start and end, with JavaScript’s end-anchor rules. The s flag does something different: it allows a dot to match newlines.
Does the match limit prevent a frozen tab?
No. The table collects up to 5,000 matches, but a single match attempt can still take a long time. Patterns with nested repetition, such as (a+)+b on a long non-matching input, can block the page because this tester has no worker timeout. Start small and simplify slow patterns.
Published by ToolsNow. How tools and sources are checked · Report a problem