πŸ”Ž Utilities

Regex Tester & Explainer

Test regular expressions with live match highlighting and capture group display. Get a plain-English breakdown of what each part of your pattern does β€” great for learning and debugging.

πŸ” Pattern
/ / gi
Flags:
Quick patterns:
Email URL IPv4 Date Name Hex color
πŸ“ Test String
πŸ“‹ Regex Quick Reference
Characters
\d Digit (0–9)
\w Word char (a-z, A-Z, 0-9, _)
\s Whitespace
. Any char except newline
[abc] Character class
[^abc] Negated class
Quantifiers
* 0 or more
+ 1 or more
? 0 or 1 (optional)
{n,m} Between n and m
*? Lazy (minimal match)
Anchors
^ Start of string/line
$ End of string/line
\b Word boundary
Groups
(abc) Capture group
(?:abc) Non-capture group
(?<name>) Named group
a|b Alternation (a or b)
πŸ“– How to Use This Tool
β–Ό
1
Enter a pattern in the regex field
2
Paste test text β€” matches highlight live
3
View capture groups and values
4
Use the cheatsheet for syntax help
πŸ“ Examples
Emails
Input: [a-z]+@[a-z]+\.[a-z]+
Output: Highlights all emails in text

What is a Regex Tester?

A regex tester is an interactive tool that lets you write a regular expression pattern and immediately see which parts of a test string it matches, with live highlighting and detailed match information including capture group values. Regular expressions are a pattern-matching language supported in virtually every programming language, and the difference between a working pattern and a subtle bug can be a single misplaced character β€” making an interactive tester invaluable for both writing new patterns and debugging existing ones.

For DevOps and SRE engineers, regular expressions are used constantly: parsing structured log formats, writing log-based alert rules in Grafana or Datadog, configuring Nginx location blocks and rewrite rules, writing input validation in scripts, extracting fields from CLI tool output in bash pipelines, and defining masking patterns for sensitive data redaction. The pattern explainer in this tool β€” which breaks each element of your regex into a labeled token with a plain-English description β€” is especially useful for reviewing patterns written by others or understanding complex expressions you inherited from a legacy codebase.

When to Use This Tool

How It Works

The tool constructs a JavaScript RegExp object from the pattern and selected flags using new RegExp(pattern, flags), then iterates over all matches in the test string using RegExp.prototype.exec() in a loop to collect each match's index, full match text, and capture group values (both numeric and named). The highlighted output is built by walking through the original string and wrapping each matched span in a <mark> element. The pattern explainer tokenizes the regex string into its constituent elements β€” character classes, quantifiers, anchors, groups, and literal characters β€” and maps each token to a color-coded block with a plain-English label, all evaluated client-side in real time as you type.

Frequently Asked Questions

What regex flavour does this tool use?

This tool uses JavaScript's built-in RegExp engine, which implements the ECMAScript regular expression specification. It supports standard character classes (\d, \w, \s), quantifiers (*, +, ?, {n,m}), anchors (^, $, \b), capture groups, non-capturing groups, named groups ((?<name>...)), and lookaheads ((?=...), (?!...)). Lookbehind assertions ((?<=...), (?<!...)) are supported in all modern browsers (Chrome 62+, Firefox 78+, Safari 16.4+). Note that some regex features from other languages β€” like PCRE's conditional patterns or atomic groups β€” are not available in the JavaScript regex engine.

How do I test regex flags?

Use the flag toggle buttons above the pattern input to enable or disable individual flags. The g (global) flag finds all matches instead of stopping after the first β€” enable this when you want to see every occurrence highlighted. The i (case-insensitive) flag makes the match ignore case differences between uppercase and lowercase letters. The m (multiline) flag changes the behavior of ^ and $ anchors so they match the start and end of each line rather than the entire string β€” essential for line-by-line log parsing. The s (dotAll) flag makes the . wildcard match newline characters as well, and the u (unicode) flag enables full Unicode character matching and proper handling of multi-byte characters.

What is the difference between a capture group and a non-capturing group?

A capture group, written as (pattern), both groups the pattern for quantifier application and saves the matched substring so it can be referenced later. In JavaScript, captured groups are accessible as match[1], match[2], etc., and in replacement strings as $1, $2, etc. A non-capturing group, written as (?:pattern), groups the pattern without saving the match β€” it is semantically equivalent but more efficient when you only need the grouping behavior (for alternation like (?:jpg|png|gif) or to apply a quantifier to multiple tokens) and do not need the captured value. Named capture groups, written as (?<name>pattern), save the match under a named key accessible as match.groups.name, making your regex code more readable and maintainable when multiple groups are present.