Regex Tester

Test and debug regular expressions with live match highlighting.

Examples:
g
Click to toggle flags

0 / 50,000 chars

About Regex Tester

Regular expressions (regex) are patterns used to match character combinations in strings. This tester lets you write a pattern, choose flags, and instantly see every match highlighted in your test string — with match position, length, and captured groups shown for each result.

How to use

Enter your regex pattern in the top field (without slashes) and your test string below it. Matches are highlighted live as you type. Toggle flags using the buttons: i for case-insensitive matching, m for multi-line mode where ^ and $ match line boundaries, and s (dotAll) to make . match newlines. The global flag is always active.

Useful regex patterns

  • \d+ — one or more digits
  • \b\w+@\w+\.\w+\b — simple email-like pattern
  • https?://\S+ — URLs starting with http or https
  • ^[A-Z] — lines starting with an uppercase letter (with m flag)
  • (?<year>\d4)-(?<month>\d2) — named capture groups for dates

About the Regex Tester

A regex tester evaluates a regular expression against sample text and shows every match in context, with capture groups highlighted. Regular expressions are powerful but notoriously hard to write correctly on the first attempt — a tester lets you iterate quickly, see the impact of each change, and avoid running a half-debugged pattern against production data.

This tester uses the JavaScript regex engine (the same engine that runs in browsers and Node.js). Patterns are written in standard JavaScript regex syntax, with support for global, case-insensitive, multiline, sticky, dot-all, and Unicode flags.

Quick refresher: regex syntax basics

A character class such as [a-z] matches any lowercase letter. The metacharacter . matches any character except a newline (unless the dotAll flag is on). Quantifiers like * (zero or more), + (one or more), ? (zero or one), and {n,m} (between n and m) repeat the preceding atom. Parentheses (…) define capture groups; (?:…) defines a non-capturing group. Anchors ^ and $ mark the start and end of a line (with multiline) or of the input. Alternation a|b matches either side. These primitives compose into almost every regex you will ever write.

Flags and their effects

The g flag finds every match instead of stopping at the first. The i flag makes matching case-insensitive. The m flag changes ^ and $ to match the start and end of each line rather than the entire input. The s (dotAll) flag lets . match newlines. The u flag enables full Unicode handling, including correct treatment of code points outside the basic plane. The y (sticky) flag anchors the match at lastIndex for incremental parsing.

How to use the Regex Tester

  1. Type a pattern

    Enter your regex in the pattern input. Use slashes only if you also want to set flags inline; otherwise the flag toggles in the UI are easier.

  2. Paste your test text

    Drop the text you want to match against in the larger input area.

  3. Read the matches

    Every match is highlighted in the text, and a list below shows the match index, captured groups, and the matched substring.

  4. Iterate

    Tweak the pattern and watch the highlights update in real time. Regex development is overwhelmingly about iteration.

Worked examples

Example 1

Input: \\b\\d{3}-\\d{4}\\b on "Call 555-1234 or 555-5678"

Result: Two matches: 555-1234, 555-5678

Phone-number-style pattern with word boundaries.

Example 2

Input: ([A-Z][a-z]+)\\s([A-Z][a-z]+) on "Alice Smith, Bob Jones"

Result: Two matches with two capture groups each

Capture groups extract first and last names.

Example 3

Input: ^#{1,6}\\s.+$ with /m on Markdown

Result: Every heading line

The multiline flag makes ^ and $ match per line.

Real-world use cases

  • Validating user input formats: emails, postal codes, identifiers.
  • Extracting structured fields (dates, URLs, hashtags) from unstructured text.
  • Search-and-replace operations across a codebase before running them in your editor.
  • Parsing log lines into named fields for further processing.
  • Sanity-checking a regex before pasting it into a production application or migration script.

Tips & common mistakes

  • Watch out for catastrophic backtracking. Patterns with nested quantifiers like (a+)+ can hang the page on adversarial input. If your regex is slow, simplify nesting.
  • When matching multiline text, set the m flag explicitly — without it, ^ and $ refer only to the whole string.
  • Escape metacharacters (.+*?(){}[]|\^$) when you want to match them literally. Forgetting is the #1 source of "the regex matches nothing" bugs.
  • Test with edge-case inputs: empty strings, strings with only whitespace, strings with the pattern at the very start or very end. These are where bugs hide.

Frequently asked questions

Does this support PCRE features like lookbehind?

It uses the JavaScript regex engine, which now supports lookahead (?=…) and lookbehind (?<=…), named capture groups (?<name>…), and Unicode property escapes (\p{…}). Some PCRE features such as recursive patterns are not available.

Why are my matches not highlighted in order?

They should be. If they aren't, check that the global flag is set; without it, the engine only returns the first match.

Is my input sent to a server?

No. The regex evaluates in your browser. Nothing is uploaded.

Can a regex hang the page?

Catastrophic backtracking can cause very long match times. If a particular pattern stalls, simplify nested quantifiers or use atomic groups.

Related tools

Last updated: June 2026 · All processing happens locally in your browser.