Regex Tester - Test a Regular Expression Live, Safely

2on /
/ Dev Tools / Regex Tester

Regular expression tester

/ /

Flags

Use $1, $2 for capture groups and $& for the whole match.

This tester runs your browser's own JavaScript engine, so the dialect is ECMAScript. Patterns written for PCRE, Python or .NET can behave differently, especially around lookbehind, atomic groups, possessive quantifiers and unicode property escapes.

What this regex tester does

A regular expression is easy to write and hard to be sure about. This page shows you what your pattern actually matched in your own text, which groups it captured and what the replacement would produce, before that pattern goes anywhere near production data.

How to use it

  1. 1 Type the pattern between the slashes and tick the flags you need.
  2. 2 Paste real text underneath, the messier the better, and press Run.
  3. 3 Read the highlighted view for a quick check, the table for the captured groups, and add a replacement to preview the rewrite.

Why the pattern runs in a separate worker

Some patterns explode. A nested quantifier such as (a+)+$ can force the engine to try an astronomical number of paths on a string that almost matches, and a regular expression already running cannot be interrupted from the page it started on. Running it in a worker means it can be terminated after two seconds, so a bad pattern costs you a message instead of a frozen tab.

Short reference

\d a digit
\w a letter, digit or underscore
\s any whitespace
. any character except a newline
^ $ start and end of the text
* + ? zero or more, one or more, zero or one
{2,5} between two and five times
(...) a capture group, read back as $1
(?<ad>…) a named group, easier to read in long patterns
[a-z] any one character from the set
a|b either the left side or the right side
\b a word boundary, matches no character itself

The dialect matters

A pattern that works here may fail in your server code and the other way round. JavaScript, PCRE, Python and .NET differ in what they support and sometimes in what the same syntax means. Test in the dialect you will deploy in, and treat this page as the right place for anything that will run in a browser.

Groups are where most mistakes hide

The match itself is often right while the captures are wrong: a group is optional and comes back undefined, or two groups swap because a bracket moved. The table shows every group of every match side by side, which is the fastest way to see that $2 is not what you assumed it was.

Nothing you type is sent anywhere

Test text is rarely made up. People paste log lines, customer records and payment references to see whether the pattern catches them. Both the pattern and the text stay in the page, so testing against real data does not mean handing that data to anyone.

Regex tester - frequently asked questions

ECMAScript, because the engine is your browser's. Lookahead and named groups work, lookbehind depends on the browser version, and atomic groups and possessive quantifiers do not exist at all. Anything you write for PHP or Python should be tested where it will run.
New
Color Converter Convert a color between HEX, RGB and HSL, build a scale of shades, and check the contrast ratio against white, black or any second color.
Popular Today
Color Converter Convert a color between HEX, RGB and HSL, build a scale of shades, and check the contrast ratio against white, black or any second color.

Related Dev Tools

MD5 Hash Generator Free MD5 hash generator: turn any text or file into an MD5 checksum in your browser - useful for integrity checks and quick fingerprinting.
Base64 Encoder & Decoder Free Base64 encoder and decoder: convert text or files to Base64 and back, entirely in your browser - nothing is uploaded to a server.
Lorem Ipsum Generator Free Lorem Ipsum generator: create placeholder text by paragraph, sentence or word count, with optional HTML tags for your design mockups.
JWT Decoder Free JWT decoder: paste a token to read its header, payload and signature in a readable form - decoding happens in your browser, nothing is sent.
URL Encoder & Decoder Free URL encoder and decoder: convert links and query parameters to percent-encoding and back, with full-URL and component modes, in your browser.

Other Tools You May Like

Word to PDF Convert Word to PDF for free: upload a DOC, DOCX, ODT or RTF file and download a properly formatted PDF in seconds - no registration or watermark.
PDF to Word Convert PDF to Word for free: upload a PDF and download an editable DOCX in seconds - no registration, no watermark and nothing to install.
Word Counter Free word counter: paste any text to count words, characters, sentences and paragraphs, and see the estimated reading time - nothing leaves your browser.
Character Counter Free character counter: count characters with and without spaces, plus words and lines, and check SEO limits for titles and meta descriptions.
Keyword Density Checker Free keyword density checker: paste text or a URL to see how often each word and phrase appears, with percentages for one, two and three-word terms.