Regex Tester

Type a pattern and some text and see every match highlighted as you type, with capture groups, positions and an optional replacement preview. JavaScript regex syntax, run by your browser: nothing is sent anywhere.

Regex Tester

or drop a file here. It stays on this device.

How it works

  1. Type the pattern without surrounding slashes and tick the flags you need (g finds all matches; i, m, s, u, y as in JavaScript). Under the flags, What the pattern means says what each piece of it matches, as your browser reads it.
  2. Paste or open the text to search. Matches are highlighted and listed as you type, with line, column, index and every capture group.
  3. Optionally enter a replacement ($1, $<name>, $& and $$ work) to preview the replaced text. Press Test pattern to confirm and download the matches as JSON or the replaced text.

Questions

Which regex flavour is this?

JavaScript (ECMAScript), exactly as your browser runs it: named groups, lookahead and lookbehind, Unicode classes with the u flag, sticky matching with y. It is not PCRE, Python or .NET, and syntax from those flavours is not translated: some of it is reported as an invalid pattern (possessive quantifiers such as a++, atomic groups), but some is accepted by JavaScript with a different meaning. \A and \Z are not anchors here: without the u flag they simply match the letters A and Z, and only with the u flag are they reported as an invalid escape. Check the highlighted matches rather than relying on an error message.

Can a pattern make the page hang?

No. Every test runs in the background, in a worker of the page's own, so the page keeps answering while a pattern works, and a test that has not finished after 3 seconds is stopped and the page says why. A pattern with nested quantifiers such as (a+)+$ on a text it cannot match tries exponentially many ways before it fails: 28 letters a followed by ! take seconds, a few more letters take hours. Rewrite such a pattern with a single repeat, for example a+$ instead of (a+)+$. In Safari, and in every browser on an iPhone or iPad, the browser's own engine gives up on such a search by itself within about a second and reports no match even when the text has one further on, so a No matches. there can be wrong; test such a pattern in Chrome, Edge or Firefox on a computer or on Android, where it is stopped after 3 seconds and the page says so. The 1,048,576-character limit on the test text bounds memory and result sizes. The pattern and text you typed were not saved anywhere, so they are lost with the tab; keep a copy of long text elsewhere.

How many matches are shown?

Up to 10,000 matches are collected. The table shows the first 500 and the highlighted view the first 200,000 characters of the text; the JSON download has every collected match with its index, text, groups and named groups.

What about zero-length matches?

Patterns like a* or ^ can match empty strings. They are listed in the table as (empty) and the search advances one character (one code point with the u flag) so it always finishes; they are not highlighted in the text view.

Does it work offline?

Keep a connection until the first test finishes successfully. You can then test offline in this open page. A spare test script loads in the background, but it may not be ready yet; after a test is stopped or replaced, you may need to reconnect before testing again. Nothing you type is uploaded.

Is my text uploaded?

No. The page loads a small script into your browser and every operation runs on your device. You can check this yourself in the browser's network panel: after the page has loaded there are no upload requests. Closing the tab discards the text.

Do I need an account or to pay?

No. These basic tools are free and add nothing to your data. The only limits are the tool's own: test text up to 1,048,576 characters as JavaScript counts them (UTF-16 units, so an emoji counts as 2), opened files up to 4 MB, 10,000 matches collected. Within them, the practical limit is your device's memory.

What does this page keep in my browser?

Nothing you open or type. While the tab is open, the tool pages keep a short list of the steps taken in it, in the tab's session storage: the step (page opened, started, succeeded, first success, used again or failed), the tool's name, the time, how many files were used and, for a failure, an error code; never a file name, the contents of a file or your text. It holds at most the latest 200 steps, and the browser deletes it when the tab closes. The page never sends it. Where a Report a problem button is shown, you can attach the last 20 steps to your report; nothing is attached unless you tick that box. In local storage the page keeps only choices you made: a Light or Dark theme until you choose System again, the language you picked with the EN / 中文 switch if it differs from your browser's language, and this tool in your recently used list if you switched that list on at the tools page.

Questions or problems

Found a problem or missing feature? Tell us. Please describe the steps; do not send confidential data.