DevUtils

Regex Tester

New

Test and debug regular expressions online for free. Real-time match highlighting, named capture groups, and full flag support (g, i, m, s, u). Works entirely in your browser — no signup required.

//
TEST STRING

About this tool

A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. Regex is used to validate input (email addresses, phone numbers), search and replace text, parse log files, extract data from strings, and much more. This tool tests a regex pattern against a test string in real time, highlights every match, shows match groups (including named capture groups), and counts the total number of matches. It supports JavaScript regex flags: g (global), i (case-insensitive), m (multiline), s (dot matches newline), and u (full Unicode).

How to use

  1. 1Enter your regular expression in the "Pattern" field.
  2. 2Type your test string in the "Test String" area — matches are highlighted in real time.
  3. 3Toggle flags (g, i, m, s, u) using the flag buttons to change matching behavior.
  4. 4Named capture groups and all match indices are displayed below the test string.

Frequently asked questions

What are regex flags?
Flags modify how a pattern is applied. g (global) finds all matches instead of stopping after the first. i makes the match case-insensitive. m makes ^ and $ match the start and end of each line rather than the whole string. s makes the dot (.) match newline characters. u enables full Unicode support and Unicode property escapes (\p{Letter}).
What are capture groups and named groups?
Parentheses () create a capture group that extracts a specific part of the match. Named groups use the syntax (?<name>...) and make your regex more readable—for example, (?<year>\d{4})-(?<month>\d{2}) captures the year and month by name.
What is the difference between .* and .*? (greedy vs lazy)?
By default, quantifiers like * and + are greedy—they match as many characters as possible. Adding ? makes them lazy—they match as few characters as possible. On the string <a><b>, the pattern <.*> (greedy) matches the entire string, while <.*?> (lazy) matches just <a>.
What are some common regex patterns?
Email (simple): ^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,}$ — IPv4: \b(\d{1,3}\.){3}\d{1,3}\b — ISO date: \d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]) — Hex color: #([0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b