Interactive Utility · Client-Side Only

Regex Tester & Debugger

Live match highlighting, capture group breakdown, and replace preview — using your browser's own RegExp engine, so results match exactly what your JavaScript code would do.

/ /

Matches & Capture Groups

#Full matchGroupsIndex

Replace Preview

What this tool actually is

A regular expression (regex) is a pattern used to search, match, or replace text — used everywhere from form validation (checking an email or phone number looks right) to log parsing, data cleanup in spreadsheets, find-and-replace across code, and scraping structured text out of messy documents. Writing a regex correctly on the first try is rare even for experienced developers, because a pattern that looks right can silently match too much, too little, or throw a syntax error on an edge case you didn't think to test. This tool exists to close that gap: type a pattern, see instantly and visually what it actually matches against real text, before that pattern ships into a form validator, a server-side filter, or a data pipeline.

How to use it

Type or paste a pattern into the pattern field (without the surrounding slashes), set flags either by typing them directly or toggling the checkboxes below the field, and paste your real sample text into the Test String box. Matches highlight live as you type, in alternating colors so adjacent matches are easy to tell apart. The Matches & Capture Groups table breaks down every match with its numbered groups and character index — useful for confirming a group actually captures what your code expects before you write match[1] or match.groups.name against it. The Replace Preview shows exactly what text.replace(pattern, replacement) would produce in real JavaScript, so you can verify a find-and-replace pattern before running it against a real file or database. The preset chips above the pattern field load ready-made patterns for common cases — including a Pakistani mobile number format — as a starting point to adapt rather than write from scratch.

Why this matters — benefits over guessing in your code editor

Testing a regex by repeatedly editing and re-running your actual application is slow and risky: a pattern that's slightly wrong can pass a couple of manual test cases and still fail silently on real user input weeks later — a classic source of validation bugs that let malformed data through or reject valid data by mistake. Because this tool uses your browser's real JavaScript RegExp engine rather than a simplified simulation, what you see here is exactly what new RegExp(pattern, flags) would do in your actual codebase — not an approximation that might behave differently once deployed. And because everything runs client-side, you can safely test patterns against real production-like data (API keys, log lines, customer records) without that data ever being transmitted anywhere.

Quick reference

\d \w \sdigit, word character, whitespace
\D \W \Sthe negated versions of the above
^ $start / end of string (or line, with the m flag)
* + ? {n,m}zero-or-more, one-or-more, zero-or-one, between n and m
(...) (?:...)capturing group / non-capturing group
(?<name>...)named capture group — access via match.groups.name
(?=...) (?!...)positive / negative lookahead
g i m s u yglobal, ignore-case, multiline, dotAll, unicode, sticky flags
Why does my pattern only match once even without the "g" flag issue?

Without the global (g) flag, JavaScript's RegExp.exec() and String.match() only return the first match by design — this tool automatically adds g behind the scenes for the highlighting and match list so you can see every occurrence, while still respecting your other flags exactly as entered.

What's the difference between greedy and lazy quantifiers?

By default, * and + are greedy — they match as much text as possible before backtracking. Adding a ? after them (*?, +?) makes them lazy, matching as little as possible instead. This matters most when a pattern like <.*> on <b>bold</b> greedily matches the whole string instead of stopping at the first >.

Why did a valid-looking pattern throw a syntax error?

Unescaped special characters — a bare (, [, or a trailing \ — are the most common cause. If you mean the literal character, escape it with a backslash (\(, \[) rather than leaving it as a regex metacharacter.

Is my data actually private when I paste it in here?

Yes — this page has no network calls at all (enforced by a strict Content-Security-Policy, not just a claim in this text), so a pattern or test string you paste here never leaves your browser tab, is never logged, and disappears the moment you close or refresh the page.

Can I test multiline text and log files here?

Yes — paste multiple lines directly into the Test String box. Enable the m (multiline) flag if you want ^ and $ to match the start/end of each line rather than only the start/end of the whole string, and s (dotAll) if you need . to also match newline characters, which it doesn't by default.

Something behaving unexpectedly, or a pattern you think this tool is getting wrong? Reach us at info@lamastudio.pk.