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.
\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* 0 or more+ 1 or more? 0 or 1 (optional){n,m} Between n and m*? Lazy (minimal match)^ Start of string/line$ End of string/line\b Word boundary(abc) Capture group(?:abc) Non-capture group(?<name>) Named groupa|b Alternation (a or b)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
- Writing log parsing patterns: Test a regex against representative log samples before deploying it to a log aggregation pipeline, an alert rule, or a log-parsing script β catching edge cases like optional fields, varying whitespace, and timestamp format variations before they reach production.
- Building input validation rules: Develop and verify validation regexes for email addresses, IP addresses, URL formats, version strings, or custom identifiers in web forms, CLIs, and Terraform variable validations without writing a single line of application code.
- Debugging and explaining inherited patterns: Paste a complex regex from a legacy codebase or a Stack Overflow answer into the explainer to see a token-by-token breakdown of what each part does, before deciding whether to use or modify it.
- Writing Nginx and reverse proxy rules: Test location match patterns and rewrite rules against sample URLs to confirm they match expected paths and capture the correct URL segments before deploying configuration changes to a production reverse proxy.
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.