A sleeping cat.

Regex Tester

Test JavaScript regular expressions against text, inspect matches, and experiment with regex flags directly in your browser.

Regular Expression

Matches are tested automatically as you type.

Pattern

0 chars

Flags

Choose the JavaScript regex flags to apply.

Test String

Matching text is highlighted automatically.

0 lines
♥

ToolTunnel is free and ad-free

Your support helps us build more tools and improve the ones you already use.

♥Support

Related Tools

More tools you may find useful.

About this tool

The Regex Tester is a browser-based tool for creating, testing, and debugging JavaScript regular expressions. Enter a pattern and test string to see matches highlighted immediately, inspect match positions, and experiment with common JavaScript regex flags.

What is a regular expression?

A regular expression, often called a regex or regexp, is a pattern used to search, validate, extract, and transform text. Regular expressions are commonly used for tasks such as finding email addresses, extracting identifiers, validating input, parsing logs, and searching source code.

This tool uses the JavaScript RegExp engine, so its syntax and behavior follow JavaScript regular expression rules.

What does this Regex Tester do?

The tester evaluates your regular expression against a test string as you type. Matching portions of the text are highlighted directly in the editor.

The tool also reports the number of matches and the zero-based character position of each match.

  • Test JavaScript regular expressions
  • Highlight matching text
  • Find all matches with the global flag
  • Test case-insensitive patterns
  • Test multiline expressions
  • Test dot-all expressions
  • Use Unicode-aware matching
  • Inspect match positions
  • Load a test string from a local file

JavaScript regex flags

  • g — Global: find all matches instead of stopping at the first match
  • i — Ignore case: perform case-insensitive matching
  • m — Multiline: make ^ and $ operate on line boundaries
  • s — Dot all: allow . to match newline characters
  • u — Unicode: enable Unicode-aware matching

Common regex use cases

  • Finding email addresses in text
  • Extracting URLs or domain names
  • Validating identifiers and simple input formats
  • Searching application and infrastructure logs
  • Extracting numbers, dates, or structured tokens
  • Finding specific words or patterns in source code
  • Testing patterns before implementing them in JavaScript

Understanding match positions

Match positions reported by this tool use JavaScript string indexes. The first character has index 0, so the index is zero-based.

The end position represents the position immediately after the matched text. For example, a match starting at index 5 with a length of 3 has an end position of 8.

Global versus non-global matching

Without the g flag, JavaScript returns only the first matching occurrence. With the g flag enabled, the tester searches for all matching occurrences in the test string.

The global flag is especially useful when you want to extract every occurrence of a pattern rather than simply determine whether one match exists.

JavaScript compatibility

Regex syntax differs between programming languages and regex engines. A pattern written for Python, PCRE, .NET, Java, or another engine may not behave identically in JavaScript.

For this reason, patterns should be tested using the same regex engine that will eventually execute them.

Privacy and security

Regex testing is performed locally in your browser. Your regular expression and test string do not need to be uploaded to a ToolTunnel backend service.

This makes the tool suitable for testing local log samples, configuration text, code fragments, and other data that should remain on your device. You should still follow your organization's security policies when handling sensitive information.

Limitations

The tester uses the browser's JavaScript RegExp implementation and therefore does not emulate every regex engine used by other programming languages.

A syntactically valid regular expression can still produce unexpected results if the pattern does not match the intended data. Regex testing should therefore include realistic sample input and edge cases.

Frequently Asked Questions

▶What regex engine does this tool use?

The tool uses the JavaScript RegExp engine provided by the browser.

▶Why does my regex work in another language but not here?

Regex syntax and features vary between engines. A pattern written for Python, PCRE, .NET, Java, or another engine may require changes for JavaScript.

▶What does the g flag do?

The g flag enables global matching, causing the tester to find all matches instead of stopping after the first match.

▶What does the i flag do?

The i flag makes matching case-insensitive. For example, a pattern matching 'hello' can also match 'Hello' or 'HELLO'.

▶Are match indexes zero-based?

Yes. Match positions use JavaScript's zero-based string indexing, where the first character has index 0.

▶Can I test a multiline string?

Yes. You can paste or load multiline text. The m flag changes how ^ and $ behave across multiple lines, while the s flag allows a dot to match newline characters.

▶Can I load a text file?

Yes. The test string area supports opening or dragging supported text-based files into the tool.

▶Is my test data uploaded?

No. Regex testing runs locally in your browser and does not require uploading your pattern or test data to a backend service.