Regex Tester

Test and debug regular expressions with real-time matching.

//

Matches

No matches found.

Related Tools

Free Online Regex Tester & Debugger

Write, test, and debug regular expressions with instant visual feedback. UtilHub's Regex Tester highlights all matches in your test string in real time, shows capture groups with distinct colors, and flags syntax errors before they break your code. Supports JavaScript regex flavor with global, case-insensitive, and multiline flags. Whether you're extracting data from logs, validating user input, or learning regex patterns, this tool shows you exactly what your pattern matches — and what it doesn't.

How to use Regex Tester

  • Enter your regex pattern — Type your regular expression in the pattern field. Start simple and add complexity — for example, start with `\d+` to match digits, then refine to `\d{3}-\d{3}-\d{4}` for US phone numbers.
  • Set flags (g, i, m) — Toggle Global (g) to find all matches instead of stopping at the first, Case-insensitive (i) to treat "ABC" and "abc" as equal, and Multiline (m) to make ^ and $ match each line start/end instead of the entire string.
  • Paste your test text — Enter or paste the text you want to test. Matches highlight in real-time with exact position indexes — for example, "Match at position 14-22" — so you can debug precisely.
  • Review matches and export — Check each match with its capture groups and position details. Copy all matched results or the refined pattern to use in JavaScript, Python, or any language that supports ECMAScript regex syntax.

Features

  • Real-time matching — Matches highlight instantly as you type your pattern. No need to press a button — see results with every keystroke.
  • Capture group highlighting — Each capture group gets a distinct color, so you can visualize exactly what each group extracts from your text.
  • Flag toggles — Enable or disable global (g), case-insensitive (i), multiline (m), dotAll (s), and unicode (u) flags with one click.
  • Match details panel — Shows every match with its index, full match text, and individual group captures in a structured table.

Frequently Asked Questions

Which regex flavor does this tool support?

This tool uses the JavaScript regex engine, which is the same engine used in all modern browsers, Node.js, and TypeScript. JavaScript regex is very similar to PCRE (used by PHP and many other languages) for most common patterns. Features like lookahead, lookbehind, and named capture groups are fully supported.

Can I test regex patterns with multiple matches?

Yes. Enable the global flag (g) and the tool will highlight and list every match in your test string, not just the first one. Each match is shown with its position, full text, and capture groups. This is essential for patterns designed to extract multiple occurrences from a text.

What are regex flags and when should I use them?

Flags modify how the regex engine searches. The global flag (g) finds every match in the text — without it, the engine stops after the first hit, which is the number-one surprise for beginners. The case-insensitive flag (i) treats uppercase and lowercase as identical, so `/hello/i` matches "Hello", "HELLO", and "heLLo". The multiline flag (m) changes ^ and $ from matching the start/end of the entire string to matching each individual line — essential when processing log files, CSVs, or any multi-line input. Most practical use cases need at least the g flag enabled.

Why is my regex only matching the first occurrence?

You need the global (g) flag enabled. By default in JavaScript's RegExp engine, the regex stops after the first successful match. For example, `/cat/` on "the cat sat on the cat mat" returns only the first "cat" at position 4. Adding the g flag (`/cat/g`) finds both occurrences at positions 4 and 19. Toggle the "Global" checkbox in UtilHub to enable this.

What are the most common regex patterns developers need?

The five patterns developers use most often are: email validation (`[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}`), URL matching (`https?://[\w\-._~:/?#\[\]@!$&'()*+,;=]+`), phone numbers (`\d{3}[-.]?\d{3}[-.]?\d{4}`), dates in YYYY-MM-DD format (`\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])`), and IPv4 addresses (`\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b`). Our Quick Patterns panel lets you load these with one click.