Swelıty
Tools for everyone

Free Online Regex Playground

Write a regular expression and test it on your own text. Matches are highlighted as you type, with their positions and groups, and you can try a replacement too.

Auto-run is on, so the matches update as you type. Write the pattern as /pattern/flags, or just the pattern. Every match is found, whatever the flags. Use the Replace tab to try a replacement such as $1. A pattern that never ends is stopped after 3 seconds.

Preview

How to use

  1. Write the pattern in the Regex tab, as /pattern/flags (for example /\\d+/g) or just the pattern.

  2. Paste the text to search in the Test text tab. The matches are highlighted in the preview.

  3. Read the Matches table for the position of each match and what each group captured.

  4. Write a replacement in the Replace tab, such as $1-$2, to see the text after replacing.

  5. Use the icons in the editor to copy the text, open a file, download a zip of your files or clear everything.

  6. Open the full screen editor for more room, and use the A buttons to resize the text.

Why use this tool

  • Highlighted matches

    Every match is marked in your text, in two alternating colours so neighbouring matches are easy to tell apart.

  • Groups and named groups

    The table shows what each capture group matched, including named groups.

  • Try a replacement

    Write a replacement with $1 or $& and see the result.

  • Stops runaway patterns

    The matcher runs in a worker that is stopped after 3 seconds, and the preview says why.

  • Nothing of yours is run

    Your pattern is only given to the regular expression engine, and no scripts of yours run.

  • Comfortable editor

    Resize the text, switch line wrapping on or off, or go full screen with the editor and preview side by side.

About this tool

Test a regular expression on your own text and see the matches as you type. Matches are highlighted in the text, and a table lists each one with its position and its groups, including named groups. Add a replacement in the Replace tab to preview the result. Use it to learn regular expressions, build a pattern for validation or search, or work out why a pattern does not match. The pattern runs in a separate worker that is stopped after a few seconds, so a pattern that never ends cannot freeze the page.

Frequently asked questions

The JavaScript flavour, the one used in browsers and Node. Features such as lookbehind and named groups work when your browser supports them.

Write the pattern as /pattern/flags, for example /hello/i. The g flag is always added so that every match is listed.

A pattern can take a very long time on some texts, usually when a quantifier sits inside another, such as (a+)+. The playground stops it after 3 seconds. Make the pattern more specific, or shorten the text.

The Regex Tester is a quick form for one pattern and one text. This playground is an editor with separate tabs, a match table with groups, a replacement preview, full screen and downloads.

Your last session is kept in this browser, so it is here when you come back. Use Download to keep a copy as a file.

Only to open the page. The matching happens in your browser, and nothing is loaded from another site.