Regex Tester

code

Quickly test regular expressions against sample text. See matches, capture groups, and error messages in real time. Great for validating patterns before using them in code.

Regex Tester
Test regex patterns with live matches and explanations
Characters: 0Words: 0Sentences: 0Lines: 0

Options

Characters: 0Words: 0Sentences: 0Lines: 0

Regex Tester - Live Matches & Flags | Free Online Tool

What is a regex tester?

A regex tester lets you paste a pattern and sample text, then shows matches and capture groups instantly. Use it to validate patterns before you ship them in code, search, or form validation.

How to use the regex tester

  1. Enter a pattern: Paste a regex without surrounding slashes (e.g., \w+@\w+\.\w+).
  2. Set flags: Start with g (global). Add i for case-insensitive, m for multiline, u for Unicode.
  3. Test text: Paste sample input below; results show live with indices and groups. Copy the clean JSON output if you need to log or share.

Why use this regex tester?

  • Instant feedback: See matches and errors as you type.
  • Capture awareness: View indices and named groups to confirm structure.
  • Privacy-first: All parsing runs in your browser; no text is uploaded.

Use case 1: Validate an email-ish pattern

Pattern: ^[\\w.-]+@[\\w.-]+\\.[A-Za-z]{2,}$
Paste a few addresses and confirm only valid ones match.

Use case 2: Extract IDs from URLs

Pattern: /posts/(?<id>\\d+)
Paste several URLs; check that id is captured correctly.

Use case 3: Clean up logs

Pattern: ERROR\\s+(?<code>\\d{3})
Paste log lines and verify the code group.

Examples

Basic example

Pattern: cat
Text: concatenate catalog cat
Output shows all cat matches with their indices.

Advanced example

Pattern: (?<user>[A-Za-z0-9_]+)@(example|textavia)\\.com
Flags: gi
Text: multiple email addresses → output lists matches and named group user.

Common errors

Invalid flag or pattern

If the regex fails to compile, you’ll see Invalid regex: with the JS engine’s message. Fix the pattern or remove unsupported flags.

Empty matches in global mode

Zero-length matches can loop; this tool advances the index automatically. If you see unexpected repeats, adjust the pattern to avoid empty matches.

Tips and proven approaches

  • Start simple, then add anchors (^, $) and groups.
  • Use non-greedy quantifiers *? +? when you want the smallest match.
  • Prefer named groups ((?<name>...)) for clarity; check them in the JSON output.
  • Turn on m for multiline anchors and u when working with emoji or accented text.

Related tools

Privacy and security

All regex evaluation happens locally in your browser using JavaScript’s RegExp engine. Your text and patterns are not uploaded or stored.

Frequently Asked Questions
The tool uses the JavaScript RegExp engine in your browser, so patterns follow JavaScript syntax and flags.
Matches are returned as a JSON array with the matched text, index, and capture groups when available.