Skip to content
  • Image CompressorImage Tools · Make photos and graphics smaller by re-encoding them as JPG or WebP, with a quality slider and optional downscaling.
  • Image ResizerImage Tools · Change the width and height of an image in pixels or by percentage, with high-quality downscaling.
  • Image ConverterImage Tools · Change the format of one or many images to JPG, PNG or WebP, with control over quality and transparency.
  • Image CropperImage Tools · Cut out part of an image with a draggable selection, aspect ratio presets and exact pixel inputs.
  • Rotate & Flip ImageImage Tools · Turn a picture by 90° or 180° and mirror it horizontally or vertically, with a live preview.
  • Merge PDFPDF Tools · Combine several PDF files into one document, in the order you choose, with optional page ranges per file.
  • Split PDFPDF Tools · Extract pages into a new PDF or split a document into several files by page, range or fixed page count.
  • Reorder PDF PagesPDF Tools · Change the page order of a PDF with drag and drop, delete unwanted pages and save the result.
  • Rotate PDFPDF Tools · Turn individual pages or the whole document by 90° steps, preview the result and save the corrected PDF.
  • Images to PDFPDF Tools · Combine photos and scans into a single PDF, one image per page, with page size, orientation and margin options.
  • JSON Formatter & ValidatorDeveloper Tools · Validate JSON with precise error locations, then pretty-print, minify or sort keys without changing any value.
  • Base64 Encoder & DecoderDeveloper Tools · Encode text or files to Base64 (standard or URL-safe) and decode Base64 or data: URLs back to text or a downloadable file.

Regex Tester

Try a regular expression on your text and see every match, capture group and replacement as you type.

Runs locally in your browser – your data is not uploaded

Loading tool…

About the Regex Tester

A regular expression (regex) describes a text pattern – for example "four digits, a dash, then two digits" – and is used to search, validate and rewrite text in code, editors, command-line tools and spreadsheets. Getting a pattern to match exactly what you mean is much easier when you can see the matches immediately.

This tester uses your browser’s own JavaScript regex engine, so the results are the same as RegExp, match and replace produce in JavaScript and Node.js. Matches are highlighted as you type, every match is listed with its position and capture groups, and Replace mode shows what a replacement string produces.

Patterns run in a background worker with a time limit, so a pattern with catastrophic backtracking cannot freeze the page. Your pattern and text stay in your browser.

How to use it

  1. Type a pattern into Regular expression, without the surrounding slashes – or click one of the Examples.
  2. Switch Flags on or off: g, i, m, s, u and y, plus d and v if your browser supports them.
  3. Paste the text to search into Test text. Matches are marked under Highlighted matches and listed under Match details with their index, length and groups.
  4. Choose Replace under Mode and enter a Replacement such as $<day>/$<month>/$<year> to see the Result after replacement, then click Copy result.
  5. Look up syntax in the Cheat sheet below the tester, and use Clear to start again.

Features

  • Live highlighting and match details: Every match is highlighted in the text and listed with its index, length and numbered and named capture groups. Empty (zero-length) matches are shown as thin markers, and with the d flag the start and end of each group are included.
  • Replace preview: Test a replacement with JavaScript’s syntax: $1 and $<name> for groups, $& for the whole match, $` and $' for the text before and after it, and $$ for a dollar sign.
  • The real JavaScript engine: Matching uses the browser’s RegExp implementation, so behaviour and syntax errors are exactly what your JavaScript code will see.
  • Protection against runaway patterns: Each run happens in a Web Worker and is stopped after 1.5 seconds. Instead of a frozen tab you get an explanation of catastrophic backtracking.
  • Examples and cheat sheet: Load simple patterns for e-mail-like text, ISO dates, hex colors and repeated words, and look up common tokens and replacement codes at a glance.

Examples

Reformatting dates

Load the ISO date example and switch to Replace: the pattern captures year, month and day as named groups, and the replacement $<day>/$<month>/$<year> turns 2024-03-15 into 15/03/2024.

Finding duplicated words

The pattern \b(\w+)\s+\1\b with the i flag finds "is is" and "the the" – even when the repeated word continues on the next line. Replacing with $1 removes the duplicate.

Extracting colors from CSS

With #(?:[0-9a-f]{6}|[0-9a-f]{3})\b and the flags g and i, the match list shows every three- and six-digit hex color in a stylesheet, while invalid values such as #12345G are skipped.

Diagnosing a slow pattern

The Slow pattern example ^(a+)+$ on a long row of "a" followed by "b" is stopped after 1.5 seconds with a warning. The nested + is the problem; ^a+$ matches the same text instantly.

Limitations and notes

  • Only JavaScript regex syntax is supported. Features of other flavours, such as possessive quantifiers, atomic groups, recursion, or \A and \Z, are not available, and the exact syntax supported depends on your browser.
  • The test text is limited to 200,000 characters. Up to 5,000 matches are listed and highlighted; the match count and Replace mode still cover all matches.
  • Each run is stopped after 1.5 seconds. A legitimate but very heavy pattern on long text can therefore be stopped as well.
  • As in JavaScript, without the g flag only the first match is found and replaced.
  • The example patterns are deliberately simple, for learning and quick searches. They are not complete validators – for example, the date example accepts 2024-02-30.
  • Index and length are counted in UTF-16 code units, as in JavaScript, so an emoji counts as two characters.

Frequently asked questions

Which regex flavour does this tester use?

JavaScript (ECMAScript), executed by your browser’s engine. Patterns that work here work the same way in JavaScript and Node.js code. Python, PCRE (PHP) and Java patterns are often similar but differ in details such as lookbehind support, inline flags and named group syntax.

Why does my pattern only find one match?

Turn on the g (global) flag. Without it, JavaScript stops after the first match – both when matching and when replacing.

What is catastrophic backtracking?

Patterns with nested or overlapping quantifiers, such as (a+)+ or (\w|\d)*, can try an exponential number of ways to match text that almost matches. The engine may then run for minutes. Making the pattern more specific – for example ^a+$ instead of ^(a+)+$ – usually fixes it.

How do I use a captured group in the replacement?

Write $1, $2 and so on for numbered groups, or $<name> for a group written as (?<name>…). $& inserts the whole match, and $$ inserts a literal dollar sign.

Do I need to escape forward slashes?

Not in this tester: the slashes around the box are only decoration, and the pattern is passed to new RegExp() directly. Inside a JavaScript regex literal such as /a\/b/ a slash must be escaped.

Is my text sent to a server?

No. Matching runs in a Web Worker inside this page, and neither the pattern nor the text is sent over the network.

More free tools