⌘

Regex Tester

Test a regular expression against sample text you provide.

Choose a file or fill the fields, then click Run tool.

About Regex Tester

Regular expressions are easy to get almost right. Before you put a pattern into form validation, a log search, a find-and-replace or a data cleanup script, you want to see exactly what it catches in real sample text. This tester shows every match and where it starts, so you can tighten the pattern before it touches production data.

How it works

The pattern and flags go to JavaScript's RegExp constructor, so the syntax is the browser's own ECMAScript flavor. The tool then lists every match with matchAll, one per line, as the matched text, an @ sign and its zero-based character index. Capture groups are not listed separately, and there is no replace preview. An empty flags field defaults to g. Flags without g, such as i alone, cause an error, because matchAll needs a global pattern. An invalid pattern shows the browser's error message.

How to use Regex Tester

  1. Enter the text or data in the format shown in the text box above (Sample text).
  2. Complete the available fields: Pattern, Flags. Use the field labels and examples shown in the workspace.
  3. Select “Run tool” and check the result before copying or downloading it.

Worked example

With the default pattern \b[A-Z][a-z]+ and flag g, the sample text Meet Ana in Paris on Monday produces four lines: Meet @ 0, Ana @ 5, Paris @ 12 and Monday @ 21. The words in and on are skipped, because they do not start with a capital letter.

Tips for a better result

  • Always include g in the flags, for example gi for a case-insensitive search. Entering only i triggers an error instead of results.
  • Type the pattern without surrounding slashes. Entering /abc/ makes the slashes part of the pattern, so it will only match literal slashes.
  • Test edge cases in the sample text too, such as empty lines, accented names and trailing spaces, before trusting a validation pattern.

Frequently asked questions

Will a pattern tested here behave the same in Python or PHP?

Often, but not always. This uses JavaScript's regex engine. Features like lookbehind, named groups and Unicode classes differ between languages, so retest in the target language for anything beyond basic syntax.

Why do I get matchAll must be called with a global RegExp?

You entered flags without g. The tool collects every match with matchAll, which requires the global flag. Add g to whatever flags you need, for example gm or gu.

How do I see capture groups?

This tester lists only the full match and its position. To check a group, temporarily make the group the whole pattern, or use lookarounds so the full match equals the part you care about.

What to check

A formatted or parsed result is not proof that code is secure, correct or production-ready. Never paste production secrets.

Read the Privacy Policy for information about local processing, connected services and advertising.