Regex Playground (Tester + Highlighter)

Test regular expressions against sample text, highlight matches, inspect capture groups, and learn common tokens. Use presets for email/URL/phone/date/CSV checks, copy shareable links, and export results.

Loading Regex Playground…

What is a regex playground?

A regex playground is an interactive place to write and test regular expressions (regex). Regex is a compact pattern language for searching, extracting, and validating text. Common uses include finding emails, URLs, phone numbers, dates, or parsing structured lines like CSV.

How to use this regex tester

Enter a pattern and choose flags like g (global), i (case-insensitive), or m (multiline). Paste test text and the tool will highlight matches and list them in a table with their indices and any capture groups.

Common tasks: validate, extract, and clean text

Regex is useful in two broad modes: validation and extraction. Validation patterns are often anchored with ^ and $ to ensure the entire string matches. Extraction patterns are usually global and designed to find multiple matches inside a larger body of text.

This page is built for both. You can quickly test a “does this match?” validator, then tweak it into a global extractor that pulls multiple results out of logs, emails, or copied documents.

Practical examples you can paste

If you are learning regex, start with small examples and grow them. Try these:

  • Find emails in text: Use the preset, then paste a paragraph with two email addresses and confirm the match table returns both.
  • Extract parts with capture groups: Pattern ([A-Za-z0-9._%+-]+)@([A-Za-z0-9.-]+) captures username (group 1) and domain (group 2).
  • Validate an ISO-ish date: Pattern ^\d{4}-\d{2}-\d{2}$ matches a YYYY-MM-DD shape. It does not verify real month/day ranges, but it catches many formatting mistakes.
  • Clean repeated whitespace: Use \\s+ to find runs of whitespace. This is useful before you copy text into a strict format.

Beginner-friendly token explanations

Regex can feel cryptic at first. The token panel explains common building blocks like \\d (digit), + (one or more), [] (character class), and grouping with (). This helps you connect the pattern you wrote to the behavior you see in the highlighted preview.

Flags and how they change results

Flags are a common source of confusion because a correct pattern can look “broken” if a flag is missing. g returns all matches instead of just the first. i ignores case, which matters for user input. m makes ^ and $ operate per line. s lets . match newlines. u enables Unicode-aware behavior in JavaScript engines, but it can change how characters are counted and matched.

Limitations: safe subset, not every advanced regex feature

This tool intentionally validates a safe subset of JavaScript regex. Some advanced constructs may be rejected so the playground can remain stable and predictable. If your pattern uses uncommon features and gets blocked, simplify it or break the task into smaller steps.

Privacy and local processing

This regex playground runs entirely in your browser. Your text is not uploaded to a server. The tool stores your last-used pattern and flags in localStorage for convenience (clearing site data removes that history).

Related tools

Regex playground FAQ

What is the difference between “match” and “search”?

A search finds a pattern anywhere in text. A validator usually anchors the pattern so the entire string must match. If you want validation, start your pattern with ^ and end with $.

Why does my pattern only return one result?

In many regex engines, you need the global flag g to return all matches. Without it, you may only see the first match even if the pattern appears many times.

How do capture groups show up in results?

Parentheses create capture groups. The match table lists each match and the captured group values so you can verify you are extracting the correct pieces.

Why are some patterns blocked?

The playground validates a conservative subset of JavaScript regex so it can behave consistently and avoid unstable patterns. If a pattern is blocked, simplify it or remove uncommon constructs.

Is my pasted text uploaded?

No. Matching and highlighting happen locally in your browser. Your text is not sent to a server.