All Over Tools logo
Tool Combiner
Analyze Tools Clean Tools Compare Tools Convert Tools Data Validation Extract Tools Format Tools Generate Tools Organize Tools Transform Tools
Audio Tools Font Tools Image Tools Subtitle Tools Video Tools
Archive Tools Document Tools Ebook Tools File Management Tools PDF Tools Presentation Tools
Config Tools Database Tools Dataset Tools JSON Tools Parser Tools Spreadsheet Tools XML Tools
Business Calculators Construction Calculators Date And Time Calculators Education Calculators Financial Calculators Food Calculators Health Calculators Math Calculators Science Calculators Sports Calculators Statistics Calculators
Blog About Us Contact Us

Regex Tester

Test a JavaScript regular expression against sample text. See highlighted matches, capture groups, and match indexes as you type.

/g
Flags

How to test JavaScript regular expressions

How to use the Regex Tester

  1. Enter a regular expression in Pattern, between the displayed slash marks.
  2. Select any buttons in Flags: g, i, m, s, u, or y.
  3. Type or paste text into Sample text, or select Upload to read a .txt file.
  4. Read Highlighted Text and Matches after changing the pattern, flags, or sample.

What JavaScript regex matches show

Highlighted Text marks each non-empty match inside the sample. Matches lists the match text, its zero-based index, its length, numbered capture groups, and named groups when the pattern includes them. A valid pattern with no results displays No matches found.

Pattern: \b\w+@\w+\.\w+\b
Sample text: Contact us at [email protected] or [email protected] for help.
Matches: [email protected], [email protected]

An invalid JavaScript pattern hides the result view and shows an inline error. With an empty Pattern, the page shows its instruction to enter a pattern and sample text. With an empty Sample text, it asks you to enter sample text before testing.

What the JavaScript regex flags change

The g button finds successive matches, while i ignores letter case. m changes how line anchors work, s lets the dot match line terminators, u enables Unicode mode, and y makes matching sticky at the current scan position. If neither g nor y is selected, the tester adds g while it scans for matches.

With Pattern cat and Sample text Cat cat, selecting i matches both words. With i off, the lowercase word matches.

How zero-length regex matches are handled

Patterns such as a* or (?:) can match an empty string. The tester marks each one with a thin red marker between characters, then advances by one UTF-16 code unit before continuing the scan.

The scan stops at 5,000 matches. At that point, the status reports capped at 5000, and the match list ends at the cap.

Where regex testing comes up

  • A developer checks an email pattern against the two addresses in the sample text, then inspects the indexes before adding the expression to JavaScript code.
  • A content editor tests numbered or named groups and checks which part of an identifier each group captures.
  • A support engineer uploads a text file, tests a multiline pattern, and downloads the match details as JSON.

When another text analysis tool fits better

Use Text Analysis Tools to choose among pattern testing, text measurement, language checks, and Unicode inspection. The Concordance Tool finds a word or phrase with surrounding context. The Unicode Property Tester checks character properties such as scripts, marks, numbers, punctuation, and symbols. The Invisible Character Detector locates hidden control characters, zero-width spaces, and bidi overrides.

Copying and downloading match details

After a match appears, Copy results copies tab-separated match number, text, index, and length when clipboard access is available. Download JSON prepares regex-matches.json with those fields plus zeroLength, numbered groups, and named groups. Both buttons stay disabled when the match list is empty.

Frequently asked questions

Which regex flavor does the Regex Tester use?

The Regex Tester uses the browser's native JavaScript regular expression engine, the same RegExp behavior used in JavaScript code.

What JavaScript regex flags can I test?

You can toggle g, i, m, s, u, and y in Flags.

How does the tester handle zero-length matches?

It shows each zero-length match as a thin red marker and advances the scan by one UTF-16 code unit after the match.

Can I export regex matches as JSON?

Yes. After a match appears, select Download JSON to prepare regex-matches.json with the current match details.

Related Tools

52 views