Regex Tester

Paste a regex pattern and test string to see every match, capture group, and match position in real time.

  • Free
  • No account
  • Runs in your browser
  • Nothing uploaded
Regex TesterNothing uploaded
Pattern
//g

Write your regex pattern above. The format shown is /pattern/flags

Flags
Test String0 characters

Write a pattern and test string, then click Test Regex to see all matches with their positions and capture groups.

Runs entirely in your browser — your input is never uploaded, logged, or stored.Privacy policy

What is Regex Tester?

Regular expressions (regex) are patterns used to match character combinations in strings. They are essential for search, validation, extraction, and text transformation. A regex pattern is written with special syntax: literal characters match themselves, while metacharacters like . * + ? and character classes like [a-z] match categories of characters.

This tester lets you write a pattern, toggle flags (global, case-insensitive, multiline), and paste any test string. Every match is highlighted inline, and each match's capture groups are shown with their exact positions. The tool validates the pattern as you type and shows syntax errors immediately.

Regex flags control how the pattern behaves. The g (global) flag finds all matches instead of just the first. The i (case-insensitive) flag ignores case. The m (multiline) flag makes ^ and $ match line boundaries instead of string boundaries. The s (dotAll) flag makes . match newlines. The u (unicode) flag enables full Unicode support.

Regex evaluation uses the browser's native JavaScript RegExp engine. Matches are found using RegExp.exec() in a loop when the global flag is set, or RegExp.test() for single-match mode.

Capture groups are extracted from the match's groups property. Named groups are labeled; numbered groups are indexed starting from 1. The full match is index 0.

Match positions are calculated using the match's index property (start) and index + match.length (end). This is exact — no estimation.

Pattern validation is performed by attempting to construct a RegExp object. If the constructor throws, the pattern is invalid and the error message is displayed.

Worked examples

  • Pattern: /\d+/g, Test: "abc 123 def 456" → 2 matches: "123" at position 4-7, "456" at position 12-15.
  • Pattern: /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/, Test: "2026-08-22" → 1 match with named groups: year="2026", month="08", day="22".
  • Pattern: /\b(\w+)\b/gi, Test: "Hello World" → 2 matches: "Hello" (group 1: "Hello"), "World" (group 1: "World").
  • Pattern: /[aeiou]/gi, Test: "Programming" → 3 matches: "o" at 2, "a" at 5, "i" at 8.
  • Pattern: /^\w+@\w+\.\w+$/, Test: "[email protected]" → 1 match (validates email-like format).

How to use Regex Tester

  1. Enter your regex pattern in the Pattern field.
  2. Toggle flags (g, i, m, s, u) as needed.
  3. Paste or type your test string in the Test String area.
  4. See matches highlighted inline and listed below with capture groups.
  5. Copy the regex with flags for use in your code.

Common errors

  • Invalid regular expression — the pattern has a syntax error. Common causes: unmatched parentheses, unclosed character classes, or invalid quantifiers.
  • Unterminated group — you opened a parenthesis ( but never closed it with ).
  • Nothing to repeat — a quantifier (*, +, ?) has nothing before it. Every quantifier needs a character or group to repeat.
  • Invalid escape — you used a backslash with a character that does not form a valid escape sequence.

FAQ

What is the difference between regex in JavaScript and Python?

The syntax for basic patterns is nearly identical. The main differences are in flags (JavaScript uses g, i, m; Python uses re.IGNORECASE, re.MULTILINE) and in advanced features like lookaheads. This tool uses JavaScript regex syntax, which works in most languages.

How do capture groups work?

Capture groups are portions of the pattern wrapped in parentheses ( ). Each group captures the text it matches. Groups are numbered from left to right starting at 1. Named groups can be referenced by name. The full match is always group 0.

What does the global flag (g) do?

Without the global flag, regex returns only the first match. With g, it finds all matches in the string. This tool shows all matches when g is enabled.

Is this tool safe for sensitive data?

Yes. Everything runs locally in your browser. No data is sent to any server. Your test strings and patterns never leave your machine.

Can I copy the regex for use in my code?

Yes. The tool shows the complete regex literal (/pattern/flags) that you can paste directly into JavaScript, or adapt for other languages.

G

Prefer AllUtil on Google

One click adds AllUtil to your Google preferences. You'll see our tools highlighted with a Preferred badge in Search and AI answers.

2× more likely to clickWorks in AI Overviews