Skip to content
ForgePlug — Logo
Developer100% Browser-BasedNo Signup

Regex Tester & Builder

The most beginner-friendly and developer-friendly Regex Playground on the internet. Test regular expressions with live highlighting, multi-color capture groups, replace and split modes. Learn regex with the exclusive Live Explainer that explains every token instantly. Debug failing patterns with intelligent failure analysis. Build regex without writing code using the visual builder. Browse ready-made patterns from an extensive library. All processing happens entirely in your browser — nothing leaves your device.

Regex Pattern

Flags:
gGlobal — find all matches, not just the first

Test Text

Live Highlighting

0 matches
Enter a regex and test text to see highlighting.

Live Explainer

Type a regex pattern to see explanations

Quick Examples

Load pre-built examples to see how regex works.

Email Extraction

[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}

URL Finder

https?://[\w.-]+(:\d+)?(/[\w./%-]*)?

Phone Numbers

\+?\d[\d -]{7,}\d

Date Extraction

\b\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])\b

Hex Colors

#[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?\b

HTML Tags

<[^>]*>

Frequently Asked Questions

My pattern matched way more text than I expected — why?
Nine times out of ten this is greediness. A quantifier like + or * grabs as much text as it can while still letting the rest of the pattern succeed, so <.+> against "<div>hi</div>" matches the whole string, not just the first tag. Add a ? right after the quantifier (<.+?>) to make it lazy instead — it'll stop at the first valid match.
The browser froze/hung when I ran my pattern — what happened?
Almost certainly catastrophic backtracking — a pattern with nested or adjacent quantifiers, like (a+)+b, run against a long input that doesn't satisfy it. The engine ends up trying an exponential number of ways to make it match before giving up. The Performance Analyzer in this tool flags these shapes so you catch them before they hit production with a longer input.
Why doesn't ^ and $ stop a bad string from 'matching'?
Because without anchors, the pattern just needs to find a match somewhere in the string, not describe the whole thing. \d{5} matches "abc12345xyz" because there are 5 digits in there. For field validation, anchor the whole pattern: ^\d{5}$.
Does my pattern or test text get sent anywhere?
No — matching runs on JavaScript's built-in RegExp engine directly in your browser. Nothing about your pattern or test text is transmitted, which matters if you're testing a regex against real log data or customer records rather than dummy text.
Can I come back to a pattern I was working on earlier?
Yes, it's saved to localStorage automatically as you type, so reopening the tool restores your last pattern, flags, and test text. There's also a Share button that encodes the pattern into a URL if you want to hand it to someone else.

Why your regex matches too much (it's almost always greediness)

The two bugs that account for most of what lands in a regex tester, and how to see them coming.

I built this after debugging the same class of regex bug in three different projects in one month — a pattern that worked fine in testing and then matched way more than intended the moment it hit real-world data with HTML tags, or quotes, or repeated delimiters in it. Regex is genuinely useful and genuinely easy to get subtly wrong, and staring at a wall of backslashes in your editor is a bad way to catch that. Seeing the match highlighted against real text is a much better way.

How it works

The engine underneath this tool is just JavaScript's built-in RegExp — the exact same one running in your browser's console, so anything that matches here will match identically in your actual code. It reads your test text character by character, and at each position it tries to line up your pattern; if a full match isn't possible from that character, it moves one character forward and tries again. With the g flag it keeps going after each match to find every occurrence; without it, it stops at the first one. When a pattern has some ambiguity in it — say a quantifier that could grab 3 characters or 30 — the engine uses backtracking: it tries the greedy option first, and if the rest of the pattern fails to match afterward, it backs off one character at a time until something works. That backtracking is powerful, but it's also where the two most common regex bugs live.

A real example — the greedy-dot bug

Say you're trying to pull the content out of the first HTML tag in <div class="a">Hi</div><span>Bye</span>, and you write <.+>. Because + is greedy by default, it matches as much as it possibly can and still succeed — which means it grabs everything from the first < all the way to the very last > in the string: the entire thing, both tags included. Add a ? right after the quantifier — <.+?> — and it becomes lazy, matching as little as possible, so it correctly stops at the first > and gives you just <div class="a">. This single character is responsible for more "why is my regex matching the whole file" questions than anything else.

Common mistakes

  • Forgetting anchors on validation patterns. \d{5} without ^ and $ will happily "validate" the string "abc12345xyz" as a valid 5-digit ZIP code, because it just finds 5 digits somewhere in there. If you're validating a whole field, anchor it: ^\d{5}$.
  • Nested quantifiers that cause catastrophic backtracking. A pattern like (a+)+b run against a long string of a's with no trailing b can make the engine try an exponential number of ways to fail, freezing the tab. This tool's performance analyzer flags these shapes before you paste them into production code where they might hit a much longer input and take down a request.
  • Not escaping the characters that mean something to regex. A literal period in an IP address or a version number needs to be \., not . — an unescaped dot matches any character, so 192.168.1.1 written as a pattern would also match 192a168a1a1. It rarely bites you in testing because your test string is usually well-formed; it bites you in production when it isn't.

Frequently Asked Questions

Everything you need to know about testing regular expressions

My pattern matched way more text than I expected — why?
Nine times out of ten this is greediness. A quantifier like + or * grabs as much text as it can while still letting the rest of the pattern succeed, so <.+> against "<div>hi</div>" matches the whole string, not just the first tag. Add a ? right after the quantifier (<.+?>) to make it lazy instead — it'll stop at the first valid match.
The browser froze/hung when I ran my pattern — what happened?
Almost certainly catastrophic backtracking — a pattern with nested or adjacent quantifiers, like (a+)+b, run against a long input that doesn't satisfy it. The engine ends up trying an exponential number of ways to make it match before giving up. The Performance Analyzer in this tool flags these shapes so you catch them before they hit production with a longer input.
Why doesn't ^ and $ stop a bad string from 'matching'?
Because without anchors, the pattern just needs to find a match somewhere in the string, not describe the whole thing. \d{5} matches "abc12345xyz" because there are 5 digits in there. For field validation, anchor the whole pattern: ^\d{5}$.
Does my pattern or test text get sent anywhere?
No — matching runs on JavaScript's built-in RegExp engine directly in your browser. Nothing about your pattern or test text is transmitted, which matters if you're testing a regex against real log data or customer records rather than dummy text.
Can I come back to a pattern I was working on earlier?
Yes, it's saved to localStorage automatically as you type, so reopening the tool restores your last pattern, flags, and test text. There's also a Share button that encodes the pattern into a URL if you want to hand it to someone else.

Tool Overview

A closer look at Regex Tester & Builder — how it works, who it's for, and where it fits in your workflow.

Regular expressions are the most powerful — and most intimidating — text-processing tool in a developer's arsenal. The Regex Tester makes them approachable with live highlighting: every match is marked in your test string the moment you type, with multi-color capture groups so you can see exactly which part of a pattern captures which part of the text. Flags like global, case-insensitive, and multiline are one click away, and replace/split modes show real-world applications in action.

The Live Explainer is the standout feature for learning: it parses your pattern token by token and explains what each piece means in plain English, from character classes and quantifiers to lookarounds and backreferences. When a pattern doesn't behave as expected, the built-in debugger analyzes why and suggests fixes — turning a frustrating session into a teaching moment. If writing regex from scratch isn't your thing, the visual builder assembles patterns from dropdowns, and a library of ready-made patterns covers emails, URLs, dates, phone numbers, and more.

Everything runs in your browser, so test strings that may contain personal or proprietary data never leave your device. It's a sandbox, a learning tool, and a debugging environment in one — no signup required.

Key Features

Everything you get with this tool, at a glance.

Live Match Highlighting

Every match and capture group is color-coded as you type the pattern.

Token-by-Token Explainer

Learn what each part of your regex does, in plain language.

Pattern Debugger

Get intelligent analysis when a pattern matches nothing or too much.

Visual Builder

Assemble patterns from dropdowns without writing a single metacharacter.

Pattern Library

Copy tested patterns for emails, URLs, dates, and dozens of common cases.

Browser-Only Testing

Your test strings are processed locally — nothing is uploaded.

How to Use Regex Tester & Builder

Get from zero to done in four quick steps — no account, no learning curve.

  1. Enter your pattern

    Type a regex such as \d{4}-\d{2}-\d{2} into the pattern field.

  2. Add test text

    Paste sample text below and watch every match highlight instantly.

  3. Toggle flags & modes

    Enable global, case-insensitive, or multiline flags; switch to replace or split mode.

  4. Explain or debug

    Open the Live Explainer to learn each token, or the debugger when results surprise you.

Practical Examples

Real input and output pairs so you know exactly what to expect.

Match an email

Input

pattern: ^[\w.+-]+@[\w-]+\.[\w.]{2,}$  text: contact@forgeplug.com

Output

✓ Matches contact@forgeplug.com

Extract dates

Input

pattern: \d{4}-\d{2}-\d{2}  text: Released 2026-07-01 and 2026-08-02

Output

2 matches: 2026-07-01, 2026-08-02

Invalid pattern

Error case

Input

pattern: (unclosed  text: hello

Output

The tool flags this input as invalid — no output is produced until the issue is fixed.

Part of Developer Essentials

Was this tool helpful?

Your feedback helps us improve Regex Tester & Builder for everyone.

Share this tool

Share
Runs in your browser100% privateNo data uploaded