# Regex Tester - JavaScript Regular Expressions, Live

Page: https://hirantha.me/tools/regex-tester
Part of: Hirantha Sandaruwan Lakshan free tools (https://hirantha.me/tools)
Updated: 2026-07-31

Test a regular expression against sample text and see every match.

This is a free tool that runs in the browser: open the page to use it. File tools process files on the visitor's own device; files are never uploaded or stored. No account, sign-up, payment or watermark.

Test a JavaScript regular expression against sample text and see every match highlighted live, along with each match's capture groups.

The pattern and flags you enter are compiled into a real JavaScript RegExp object and run against your test text using the same engine your browser uses everywhere else.

With the global flag enabled, every match in the text is found and highlighted, not just the first - matching how most real-world regex usage in code actually runs.

Each match's numbered capture groups are listed separately below the highlighted text, useful for confirming a pattern extracts the right pieces before using it in code.

Q: Is my pattern or test text uploaded anywhere?
A: No, matching runs entirely in your browser tab using the native RegExp engine.

Q: Which flags are supported?
A: The common ones: g (global), i (case-insensitive), m (multiline), and s (dot matches newline).

Q: What happens if my pattern is invalid?
A: The JavaScript engine's own syntax error is shown directly, the same message you'd see in a browser console.

Q: Does this match the same regex flavour used in Python or PCRE?
A: No - this uses JavaScript's regex engine specifically, which differs in some details from Python's `re` module or PCRE.

Q: Does it show capture groups?
A: Yes, each match is broken out with its groups, which is usually the fastest way to see why a pattern isn't extracting what you expected.

Q: Why does my pattern match more than I expect?
A: Almost always greedy quantifiers. .* takes as much as it can; adding a question mark to make it .*? makes it take as little as possible.

Q: How do I match across multiple lines?
A: The m flag makes ^ and $ match at each line break, and the s flag makes . match newline characters too. They solve different problems and are often needed together.

Q: Can a regex hang the page?
A: Certain patterns with nested quantifiers can backtrack catastrophically on the wrong input. If typing a pattern makes things freeze, that's what happened - simplify the nesting.

Sources: Regular expression - Wikipedia (https://en.wikipedia.org/wiki/Regular_expression); RegExp - MDN (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)

Related tools:

- [Diff checker](https://hirantha.me/tools/diff-checker.md): Compare two blocks of text and see what changed, line by line.
- [JSON formatter & validator](https://hirantha.me/tools/json-formatter.md): Pretty-print, minify, and validate JSON with clear error locations.
- [Find and replace text](https://hirantha.me/tools/find-and-replace-text.md): Find and replace in pasted text with plain or regular expression matching, whole word and case options, several rules in order, a live match count and undo.
- [Cron expression explainer](https://hirantha.me/tools/cron-expression-explainer.md): Paste a five-field cron expression to read it in plain English, see a field-by-field breakdown and list the next 10 run times in any time zone.
