Skip to content
Este site está disponível em português
Toolbench

Try: compress pdf, iphone photo, 15% of 240

    Regex Tester

    Type a pattern and see what it matches, groups included.

    Matches

    The answer appears here as you type.

    Guide: The pattern, the text, and what it catches2 min read

    The pattern, the text, and what it catches

    Type the regular expression in the side panel and paste the text to test. Every match is highlighted in the text itself, and underneath comes the list with each match's position and the value of every capture group, named ones included. The example the page opens with finds the email addresses in a sentence and skips what only looks like one.

    With “Replace with” filled in, the output becomes the text with the matches replaced: $1 for the first group, $<name> for a named one. It is the quick way to check a replace before running it on a whole file — masking the last digits of phone numbers, turning dd/mm dates into yyyy-mm-dd.

    Why a pattern can hang

    JavaScript's regex engine backtracks: when an attempt fails, it goes back and tries another route. With nested quantifiers such as (a+)+ the number of routes grows exponentially with the length of the text, and an ordinary line can take minutes. Here the test runs in a separate worker and is stopped after one second, with a warning. If that happens, rewrite the pattern: the same problem takes down servers.

    Nothing is uploaded

    The pattern and the text stay in this tab, which matters when the text is a log or a data export with personal information. To compare a text before and after a replace, use text compare.

    Frequently asked questions

    Which regex flavour is this?

    JavaScript's, the same one your browser and Node.js use, with the u flag on so Unicode and named groups work. Patterns that rely on lookbehind, named groups and \p{…} classes work; PCRE-only features such as possessive quantifiers or recursion do not.

    Why did my pattern stop with a timeout?

    It took more than a second, which almost always means catastrophic backtracking: nested quantifiers like (a+)+ or (.*)* that try an exponential number of ways to match. The test runs in a separate worker so the page never freezes. The same pattern can hang a server, so it is worth rewriting.

    How do I use capture groups in a replacement?

    Fill in “Replace with”: $1 is the first group, $2 the second, $<name> a named group and $& the whole match. The output becomes the text with every match replaced.

    Why is the g flag always on?

    Because a tester is for seeing every match. The i, m and s flags are switches: ignore case, make ^ and $ work per line, and let the dot match line breaks.

    Is my text sent anywhere?

    No. The pattern runs in your browser, in a worker on this page, and nothing is uploaded — useful when the text is a log with personal data.

    Same drawer