Development and data

How to test a regular expression with fictional text

A regular expression describes a text pattern. Short tests help check what it matches before using it in a program.

Before you start

Text is processed in the browser. Consider the content before using it and read the privacy policy.

Privacy

How to use it

  1. Enter [A-Z]{2}-[0-9]{3} as the pattern and leave flags empty.

  2. Enter Pedido AB-123 as the text and run the test.

  3. Replace the text with Pedido sem código and test again.

Regex Tester

Worked example

The pattern looks for two uppercase ASCII letters, a hyphen and three digits. The tool finds AB-123 at zero-based index 7.

Result: AB-123 at index 7; the second text has no match.

Limits and checks

Syntax is JavaScript RegExp and compatibility with other engines is not guaranteed. Limits: 250 UTF-16 code units for the pattern, 20,000 for text, up to 100 matches and a one-second worker timeout. One test does not establish safety or coverage of every case.

Next step

To review data used in another test, see the JSON guide.

How to format and check JSON before sharing it
Back to the blog