ToolsKit

Regex Tester

Test JavaScript regex patterns.

Test JavaScript regular expressions against sample text and inspect matched values and capture groups.

Loading the interactive tool… This page needs JavaScript to run the Regex Tester.

How to use Regex Tester

  1. Paste the data, code, token, or value you need to inspect.
  2. Set any format, encoding, or validation options.
  3. Run the tool and inspect the result or diagnostic output.
  4. Copy the output into your terminal, editor, API client, or project.

How Regex Tester works

Enter a pattern and flags, then paste test text. The tool builds a JavaScript RegExp and returns a JSON array listing each match, its index in the text and its capture groups. With the g or y flag it lists every match; without them it reports only the first. The default is the digits pattern with the g flag. An invalid pattern or flag shows the engine's error message, and the dialect is JavaScript only.

Worked example

Input: pattern (\d+)-(\w+), flags g, text 12-ab 7-z → Output: two matches, 12-ab at index 0 with groups 12 and ab, and 7-z at index 6 with groups 7 and z.

Common uses

  • Try a validation pattern for a form field before putting it into code.
  • See exactly which capture groups a pattern returns for sample log lines.
  • Check whether the i, m or s flag changes how a pattern behaves.

Best for

  • form validation rules
  • log and text parsing
  • debugging regular expression behavior

Tips for better results

  • Validate the output before using it in production code.
  • Treat tokens, credentials, and secrets as sensitive even when processing happens locally.
  • For large payloads, keep an original copy so you can compare changes.

Frequently asked questions

Which regex flavour is used?

The JavaScript (ECMAScript) engine built into your browser.

What do the g, i and m flags do?

g finds all matches, i ignores case and m makes ^ and $ match at line boundaries.

Why does my pattern match too much?

Quantifiers like .* are greedy; use .*? for a lazy match.

Related tools

Explore tool categories