Utilo

Regex Tester

Test and debug JavaScript regular expressions with live match highlighting, capture groups and flags.

What this regex tester does

Regular expressions describe text patterns compactly, but they are notoriously hard to read and easy to get subtly wrong. This tester runs your pattern with the JavaScript regex engine, highlights every match in the test string as you type, lists capture groups and named groups for each match, and lets you toggle the g, i, m, s, u and y flags with one click.

How to use it

  1. Enter the pattern between the slashes, without delimiters, for example (\w+)@(\w+)\.com.
  2. Toggle flags: g finds all matches, i ignores case, m makes ^ and $ match at line breaks, s lets . match newlines, u enables full Unicode, y anchors at the last position.
  3. Paste sample text into Test string.
  4. Matches are highlighted in the middle panel; groups are listed below with their positions.

Practical examples

  • Extract order numbers: ORD-(\d{6}) with the g flag captures every six-digit number following ORD-.
  • Validate a slug: ^[a-z0-9]+(?:-[a-z0-9]+)*$ accepts my-first-post but rejects double hyphens and uppercase.
  • Named groups for dates: (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) makes code like match.groups.year self-documenting.
  • Log filtering: ^ERROR.*timeout with the m flag finds lines that start with ERROR and mention a timeout.

Tips and edge cases

  • Escape special characters . * + ? ^ $ { } ( ) | [ ] \ / when you mean them literally.
  • Quantifiers are greedy by default. <.+> matches from the first < to the last >; use <.+?> for the shortest match.
  • Nested quantifiers such as (a+)+ can cause catastrophic backtracking on long inputs. Prefer specific character classes.
  • Without the u flag, emoji count as two characters and \w never matches accented letters.
  • The tester stops after 1,000 matches to keep the page responsive.

Frequently asked questions

Which regex flavour does this use?

The JavaScript (ECMAScript) engine built into your browser. It supports lookbehind, named groups and Unicode property escapes such as \p{L}. Syntax like possessive quantifiers from PCRE is not supported.

Why does my pattern match an empty string?

Patterns that can match zero characters, such as a*, succeed at every position. Use + instead of * or add anchors.

Can I validate email addresses with a regex?

A simple pattern like ^[^\s@]+@[^\s@]+\.[^\s@]+$ catches typos. Full RFC 5322 validation is impractical; send a confirmation email instead.

Why does ^ only match the first line?

Without the m flag, ^ and $ refer to the start and end of the entire string. Enable m to match at each line.

Yes. All processing happens directly in your browser using JavaScript, Web Workers and Web APIs. Nothing you type, paste or upload is sent to our servers.