Regex Tester

/ /

Type a regular expression, paste the text to test it against, and the tester runs the pattern and lists every match it finds. Each result shows where the match starts and the contents of every capture group, so you can see exactly what the pattern picked up. Toggle the case-insensitive, multiline and dotall flags to change how the pattern behaves.

How to test a regex

  1. 1

    Enter your pattern

    Type the expression without delimiters; the tester wraps it in `/ /` for you. An invalid pattern shows a clear error message instead of failing silently.

  2. 2

    Choose the flags

    Turn on `i` (case-insensitive), `m` (multiline) or `s` (dotall) to match the way you need.

  3. 3

    Paste the test text

    Add the text you want to search. The tester scans all of it and finds every match, not just the first.

  4. 4

    Inspect the matches

    Each match lists its position (offset) in the text, the full match, and every numbered capture group.

What the tester shows you

Running a pattern in your head, or with a quick grep, tells you whether something matches. The tester also shows:

  • Every match, with its position. It always searches the whole text and reports each match with the character offset where it begins.
  • Which group captured what. Each match is broken into its full match and the numbered capture groups, so you can confirm a (...) grabbed the piece you expected.
  • What the flags change. Toggle i, m or s and run the test again to see how case-insensitive, multiline or dotall matching changes the result.

The flags, in plain terms

Flag Name What it changes
i Case-insensitive A also matches a, and the reverse
m Multiline ^ and $ match at the start and end of each line, not just the whole text
s Dotall . also matches newline characters

Matching is always global: the tester returns every match in the text, so there is no separate “global” flag to set. Patterns run on the PCRE engine with Unicode support, so classes like \w and \d behave consistently on international text.

Common regex problems this helps you spot

Symptom Usual cause
One giant match covering everything .* is greedy; use .*? or a negated class like [^"]*
^ or $ only matching once Missing the m flag on multi-line text
. stops at line breaks Missing the s flag
Capture groups in an unexpected order Nested ( shift the group numbers; count them left to right
A pattern that runs slowly Nested * or + over overlapping choices causes heavy backtracking

Tips for faster, safer patterns

  • Anchor with ^ when the match starts at the beginning, so the engine does not scan the whole string.
  • Prefer a character class ([abc]) over alternation (a|b|c); classes are faster in every major engine.
  • Replace a greedy .* with a negated class such as [^"]* when you know the terminator, so there is no backtracking.

Frequently Asked Questions

It runs your pattern with PCRE, the engine built into PHP, with Unicode mode on. Syntax specific to PCRE, such as \d, \b and lookarounds, works as expected. If you will deploy the pattern in JavaScript, Python or another language, check the small syntax differences before you ship.

Every match. The tester always searches the whole text, so there is no separate “global” flag to set. Each match is listed with its position in the text.

Yes. Each match is broken down into the full match and every numbered capture group, so you can confirm which part of the text each (...) captured.

i makes matching case-insensitive, m makes ^ and $ match at each line boundary, and s lets . match newline characters. Turn them on or off and run the test again to compare the results.

The tester shows a clear error message describing the problem, such as an unbalanced bracket or an unterminated group, instead of silently returning no matches.

Related Tools

Tool available in other languages