Regex Tester

Test JavaScript regular expressions, flags, and capture groups instantly.

Presets:
Advanced — Step limit 10000

Checking a flag here updates the Flags input above, and vice versa.

Execution
Matches
Capture Groups
Input Chars
Exec Time (ms)
Steps Taken

What is Regex Tester?

A regex tester is an interactive tool that lets you write regular expressions and see matches against sample text in real time. Instead of guessing whether your pattern works, you get instant feedback: highlighted matches, capture groups, index positions, and execution stats. The tool uses JavaScript's native RegExp engine, so patterns behave exactly as they would in Node.js or browser code.

Regular expressions power log parsing, input validation, search-and-replace, and data extraction. When you need to extract emails from a log file, validate phone numbers in a form, or find all URLs in a document, regex is the go-to solution. A regex tester helps you build and debug these patterns before committing them to production. Common use cases include sanitizing user input, parsing structured text, and implementing search filters.

How to Use Regex Tester

  1. Enter your regex pattern in the Pattern field (e.g. \d{3}-\d{3}-\d{4} for US phone numbers).
  2. Add optional flags in the Flags field: g for global (all matches), i for case-insensitive, m for multiline.
  3. Paste or type your test text in the Test text area.
  4. Click Run Regex or press Ctrl+Enter to execute. Matches appear in the output with index positions and capture groups.
  5. Use the Preset chips (Email, URL, Date, Phone, UUID, IP) to load common patterns and tweak them.
  6. Open Advanced to preview find-and-replace output using $1, $2 for capture groups, or adjust the step limit to guard against catastrophic backtracking.

Tips & Best Practices

Use the flag toggles in Advanced to sync g, i, m, s, u, and y without typing. The Pattern Tokens view explains each part of your regex—helpful when learning or debugging complex patterns. If execution is slow or the step limit is hit, simplify quantifiers (avoid nested * or +) or use lazy matching (? after a quantifier). For replace previews, remember that $& is the full match. Press Ctrl+Shift+C to copy results and Esc to clear.

When to Use This Tool

Use the Regex Tester when validating patterns for form validation, log parsing, or search-and-replace scripts. It's ideal before deploying regex to production or when debugging why a pattern fails on edge cases. For related tasks: use the HTML encode/decode tool to safely embed regex in HTML, the Base64 encoder for encoding binary or text, or the JSON formatter when parsing structured data alongside regex.

Frequently Asked Questions

What is a regex tester?

A regex tester lets you enter a regular expression and sample text, then see which parts match. It shows match count, capture groups, and index positions. Useful for debugging patterns before using them in code.

What regex flags are supported?

JavaScript flags: g (global), i (case-insensitive), m (multiline), s (dotall), u (unicode), y (sticky). Enter them in the Flags field, e.g. gi for global and case-insensitive.

How do I test capture groups?

Use parentheses in your pattern, e.g. (\\d+)-(\\w+). The output shows each match with its captured groups. The stat card displays the number of capture groups found.

Why does my regex show an error?

Invalid syntax (unclosed brackets, invalid escapes) causes errors. Backslashes must be escaped in the input: use \\d not \\d. Check the error message for the exact issue.

Is this JavaScript regex or PCRE?

This tool uses JavaScript's RegExp engine. Syntax differs slightly from PCRE (e.g. no lookbehind in older JS). For text encoding, try our HTML encode/decode or Base64 encoder.