πŸ† US-Registered Digital Marketing Agency Trusted by 200+ brands Β· USA Β· UK Β· Canada Β· AUS
DEVELOPER TOOL

Regex Tester β€” live pattern matching & highlighting

Test a regular expression against real text and instantly see every match, capture group, and flag effect highlighted in place.

Do not include the surrounding slashes β€” just the pattern itself.
Common flags: g (global), i (case-insensitive), m (multiline ^ $), s (dot matches newline), u (unicode).
Matches found
0
 
0
Chars in test string
0
Capture groups total
β€”
Flags in use
β€”
Pattern validity
Tip: add the g flag to find every match instead of stopping at the first one β€” this tool applies it automatically for highlighting either way.

Match details

Advertisement

A regex tester is the fastest way to find out whether a regular expression actually does what you think it does before it ships inside a form validator, a log parser, or a find-and-replace script. Regular expressions look like a burst of punctuation to anyone reading them cold, but they are a real, compact pattern language, and the only way to get comfortable with that language is to run patterns against real text and watch what matches and what doesn't.

This page runs entirely in your browser using JavaScript's native RegExp engine β€” nothing you type is uploaded anywhere. At Arb Digital we build regex-heavy logic constantly, from URL rewrite rules to email validation to log analysis dashboards, and this tester is the same style of tool we reach for internally, cleaned up and made free for anyone to use.

What This Regex Tester Does

Type or paste a pattern into the pattern field, set any flags you want, and paste your test text into the test string box. The tool compiles your pattern with JavaScript's RegExp constructor, runs it against the text on every keystroke, and immediately shows you three things: how many matches were found, the test string with every match visually highlighted in place, and a breakdown of each match including its numbered and named capture groups. If the pattern is invalid β€” an unmatched parenthesis, a bad escape sequence β€” the tool catches the JavaScript error and shows you the exact message instead of failing silently, which is often the fastest way to spot a typo.

Because the highlighting updates live, you can iterate on a pattern the way you would in a real regex-testing session: add a quantifier, watch the match count change, tighten a character class, watch it change again. That tight feedback loop is the entire point of a regex tester β€” it turns a trial-and-error process that would otherwise mean editing code and re-running a script into something you can do in seconds.

How to Use It

  1. Write your pattern. Enter it without the leading and trailing slashes that some languages use β€” just the raw pattern, like ^\d{3}-\d{4}$.
  2. Set your flags. Add g to find all matches, i to ignore case, m to make ^ and $ match line boundaries instead of only the start and end of the whole string, and s to let . match newline characters too.
  3. Paste your test text. Use a real sample β€” actual log lines, actual user input, actual filenames β€” rather than a toy example, since edge cases hide in real data.
  4. Read the highlights. Every match is wrapped in a highlighted span directly inside your test string, so you can see exactly where matches start and stop, including whether a match is shorter or longer than you expected.
  5. Check the match details panel. Each match lists its index position in the string and, if your pattern has parentheses, every capture group's exact value β€” including named groups written as (?<name>...).
  6. Refine and repeat. Adjust the pattern based on what you see, and the results update instantly with no button click required.

How Regex Matching Actually Works

Underneath the syntax, a regular expression engine reads your pattern and your input text left to right, trying to line up the pattern against the text starting at position zero. If it fails, it slides forward one character and tries again, repeating until it either finds a match or runs out of string. This is why placement matters so much: a pattern without an anchor can match anywhere inside a longer string, which is often not what a beginner intends. The official reference for this behavior, including the full list of supported syntax, is MDN's Regular Expressions guide, which documents exactly how JavaScript's engine (the one powering this tool) interprets every token.

Two engine families exist in the wild β€” backtracking engines like the one in JavaScript, Python, and PCRE, and finite-automaton engines like RE2 and Go's regexp package. Backtracking engines are more expressive (they support backreferences and lookaround) but can, on certain pathological patterns, take exponential time on certain inputs. Automaton-based engines guarantee linear time but drop some features. JavaScript's engine is a backtracking engine, so understanding backtracking is genuinely useful, not just academic trivia.

Advertisement

Anchors, Character Classes and Quantifiers

Anchors pin a match to a position rather than a character. ^ means "start of the string" (or start of a line with the m flag), and $ means "end of the string" (or end of a line with m). \b is a word boundary β€” the invisible seam between a word character and a non-word character β€” which is why \bcat\b matches "cat" in "the cat sat" but not the "cat" inside "category".

Character classes describe a set of acceptable characters at one position. [abc] matches exactly one of a, b, or c. [^abc] matches any single character that is not a, b, or c. Shorthand classes save typing: \d is any digit (equivalent to [0-9]), \w is any word character (letters, digits, underscore), and \s is any whitespace character including tabs and newlines. Their uppercase counterparts β€” \D, \W, \S β€” match the opposite set.

Quantifiers control how many times the preceding token may repeat. * means zero or more, + means one or more, ? means zero or one (optional), and {n,m} means between n and m repetitions β€” {3} means exactly three, {2,} means two or more. By default quantifiers are "greedy": they consume as much text as possible before backtracking to satisfy the rest of the pattern. Adding a ? after a quantifier makes it "lazy" instead, so <.+?> stops at the first closing bracket rather than the last one β€” a distinction that trips up almost everyone the first time they try to match HTML-like tags.

Groups, Flags, and Why They Change Everything

Parentheses (...) create a capture group β€” a sub-match the engine remembers and reports separately, numbered left to right starting at 1. Group 0, reported as the whole match, is always the entire matched text. Non-capturing groups, written (?:...), let you group alternatives with | without adding a numbered entry to the results, which keeps your group numbering predictable in longer patterns. Named groups, written (?<label>...), let you reference a capture by a readable name instead of a position number, and this tester displays them separately in the match details panel whenever your pattern uses one.

Flags change how the whole pattern behaves rather than what any single token matches. The g (global) flag is the difference between "find the first match" and "find every match" β€” without it, most engines stop after the first hit. The i flag makes matching case-insensitive, so [a-z] also matches uppercase letters. The m (multiline) flag changes what ^ and $ mean when your test string has multiple lines, anchoring to each line rather than the whole block. The s (dotAll) flag lets . β€” which normally matches "any character except a newline" β€” match newlines too, which matters a lot when you're testing a pattern against multi-line text like this tool's sample data.

Escaping Literal Special Characters

Twelve characters carry special meaning in a regex: . * + ? ( ) [ ] { } ^ $ plus | and \ itself. If you want to match one of them literally β€” a real period in a domain name, a real dollar sign in a price β€” you must escape it with a backslash, as in \. or \$. Forgetting this is the single most common source of "my pattern matches too much" bugs: an un-escaped . in example.com will happily match examplexcom too, because an un-escaped dot means "any character," not "a literal dot." This tester makes that mistake visible immediately β€” paste text with a stray character where the dot should be and watch it highlight anyway.

A Word About Catastrophic Backtracking

Because JavaScript's engine backtracks, certain patterns can, on specific unlucky input, take an amount of time that grows exponentially with the length of the string β€” a problem known as catastrophic backtracking. The classic trigger is nested quantifiers, like (a+)+$ tested against a long string of a's followed by a character that breaks the match. Every combination of how the inner and outer + could have split up the a's gets tried before the engine gives up, and that combinatorial explosion is what freezes a page or a server process. The practical defense is to avoid nesting repeatable groups inside other repeatable groups where possible, prefer specific character classes over broad ones like . inside a repeated group, and test unfamiliar patterns β€” especially ones sourced from the internet β€” against short strings first before trusting them on large input.

Need this logic built into a real product?

Arb Digital builds the validation, parsing, and automation that regular expressions like these end up powering in production β€” forms, search filters, content pipelines, and SEO tooling. If a pattern you're testing here is destined for a live site, we can build the surrounding system properly.

See Our Services All Free Tools

Common Mistakes to Avoid

  • Forgetting the global flag when you expect multiple matches but only see one β€” add g.
  • Using . when you mean a literal period β€” escape it as \. or your pattern will match far more than intended.
  • Greedy quantifiers eating too much. <.+> against <a>text</a> matches the whole string, not just <a> β€” use <.+?> or a specific character class instead.
  • Assuming ^ and $ mean per-line without the m flag β€” by default they refer to the whole string, not each line.
  • Nesting repeatable groups like (a+)+, which risks catastrophic backtracking on the wrong input.
  • Not testing edge cases β€” empty strings, extra whitespace, mixed case, and unusually long input all deserve a quick check before a pattern ships.

Related Free Tools From Arb Digital

Once your pattern is right, chain it into the rest of your text workflow: the Find and Replace Text tool applies regex-style substitutions across a whole document, the Diff Checker shows exactly what changed after you run a substitution, the Character Counter checks your final text against length limits, and the Case Converter normalizes casing before or after a regex pass. See everything else in our free online tools hub.

Frequently Asked Questions

Is my pattern or test text sent to a server?

No. This tool runs entirely in your browser using JavaScript's built-in RegExp engine β€” nothing is uploaded, logged, or stored.

Why does my pattern match nothing even though I can see the text?

Check your flags first β€” a missing i flag on a case-sensitive pattern is the most common cause, followed by an un-escaped special character changing what the pattern actually looks for.

What's the difference between a capture group and the whole match?

The whole match (sometimes called group 0) is everything the pattern matched. A capture group is a specific parenthesized sub-part of that match, useful when you only want to extract a piece of it, like the domain from an email address.

Why do some capture groups show "(no match)"?

That happens when a group sits inside an alternation or an optional quantifier and simply didn't participate in that particular match β€” it's normal, not an error.

Does this tool support lookahead and lookbehind?

Yes β€” JavaScript's RegExp engine supports both, written as (?=...) for lookahead and (?<=...) for lookbehind, along with their negative forms (?!...) and (?<!...).

My pattern seems to freeze the page β€” what happened?

You've likely hit catastrophic backtracking, usually from nested quantifiers like (a+)+ against a long string. Simplify the pattern or avoid nesting repeatable groups.

This tool runs entirely in your browser β€” your pattern and test text are never uploaded or stored anywhere.

Advertisement

πŸ‘‹ Hey! Want to grow your business? Ask me anything β€” a free marketing proposal is on the table!