Neatbo.

JavaScript regex tester

Test JavaScript patterns against text and inspect matches, positions and capture groups.

Browser-local processingInputPattern + textOutputMatches and groups
  1. 1Add input
  2. 2Adjust settings
  3. 3Get your result

Tool input and files are processed in this browser without being uploaded.

Your input
0 characters · 0 bytes
Options

Complete the required options first. You can keep the defaults for the rest.

Enter JavaScript pattern source directly, with flags in the next field. The tool does not remove surrounding slashes, trim spaces or add escapes. An empty pattern is valid.

Use each lowercase flag at most once: i, m, g, s, u, y, with no spaces. Repeated matching is enabled by g, y, or both. Sticky y starts at 0 and stops at a gap; it cannot skip ahead. With neither flag, only the first match is retained.

Inputs are kept temporarily in this tab when switching tools. Refreshing or closing clears them; large results may need to be regenerated.⌘ / Ctrl + Enter to run

Preparing the tool…

Before you start

Try a JavaScript regular expression with your sample text. Review highlighted matches, captured groups and start/end offsets, then copy the complete JSON result.

How to use this tool

  1. Enter your sample in Test text, or load the example. An empty sample is allowed.
  2. Enter the pattern source and flags in their separate fields, then select Test expression. Do not wrap the pattern in /.../ delimiters.
  3. Check the highlighted text, positions and groups. Copy the JSON to keep all retained matches together with the sample text.

Supported inputs and limits

Patterns can use up to 4 KiB and test text up to 256 KiB, measured as UTF-8 bytes. The 2-second processing timeout starts when the Worker is ready. Loading has a separate 30-second timeout.

Start and end positions refer to the whole match and use zero-based UTF-16 code-unit offsets. The end offset points just after the match.

At most 1,000 matches are retained. The tool stops after retaining the 1,000th and sets capped; it does not check for a 1,001st match. Count reports the matches retained, so capped does not prove that more matches exist.

Worked example

Example input

ab12 cd34
Example options
{
  "pattern": "(\\d+)",
  "flags": "g"
}

Example output

{
  "matches": [
    {
      "index": 2,
      "end": 4,
      "text": "12",
      "groups": [
        "12"
      ],
      "named": {}
    },
    {
      "index": 7,
      "end": 9,
      "text": "34",
      "groups": [
        "34"
      ],
      "named": {}
    }
  ],
  "capped": false,
  "count": 2
}

When something does not work

For an invalid expression, check the pattern and flags. If a size limit is reached, shorten the pattern or test text. For a processing timeout, simplify the expression or use a smaller sample, then test again. After cancelling, you can start a new test.

Frequently asked questions

Is my test text sent to a server?

Matching runs in a Worker in your browser. This tab may temporarily keep a recent draft while you switch tools, subject to cache limits. Refreshing or closing the tab clears it. Copy any result you want to keep; the copied JSON includes your sample text.

What do the result fields mean?

The copied JSON contains sample, matches, capped and count. Each match has a zero-based index, an exclusive end, matched text, numbered groups and a named-group object. Unmatched numbered groups are null; unmatched named entries are omitted from the JSON. Count is the number of retained matches.

Are empty inputs or zero-length matches allowed?

Yes. Empty pattern source and empty test text are valid. A zero-length match is recorded even though its text is empty. With g or y, repeating an empty match advances by one UTF-16 code unit, or by a surrogate pair when u is enabled. A count of 0 means no match was retained.

Documentation & further reading

Related tools