Regular expression
Test string
Match details
Replacement
In the replacement string use $1 / $2 for capture groups, $& for the whole match, $<name> for a named group.
Pattern explanation
Syntax cheatsheet
Ready-made patterns
One click loads the pattern, flags and a matching sample text.
Features
- Live matching: every hit in the test text is highlighted as you type, alternating colors separate the matches.
- All six JavaScript flags - g / i / m / s / u / y - toggle with one click; invalid patterns report the engine's own error message.
- Match details list every hit with its offset and length, plus the value and range of every numbered and named capture group.
- A replacement view supporting $1, $& and $<name> references previews the rewritten text instantly, one click to copy.
- A token-by-token explainer and a syntax cheatsheet break any pattern down into plain language; common building blocks insert at the cursor.
- 100% client-side: your text is matched only by the RegExp engine inside your own browser - nothing is ever uploaded. UI in English / 简体 / 繁體.
How to use
- Type a pattern in the top field (no surrounding slashes needed) and toggle flags with the g/i/m/s/u/y buttons.
- Paste your text below - matches highlight instantly; if the pattern is invalid the reason appears under the input.
- Match details list every hit and its groups; hover an entry to locate it in the text. Fill in the replacement box to preview $-references.
- Learn unfamiliar syntax from the cheatsheet (click to insert) or load a ready-made pattern such as email, URL or IPv4 from the examples.
FAQ
- Is the engine the same as on other regex sites?
- This page runs your pattern with the JavaScript regex engine built into your own browser (ECMAScript). Nothing is sent to a server. Behaviour can differ slightly between Chrome / Firefox / Safari (mostly how soon new syntax is supported), and server-side flavors (Python / Java / PCRE) are similar but not identical, so check the engine you will actually deploy to.
- Why does my pattern keep showing no matches?
- Usual suspects: no g flag, so only the first hit counts; ^ and $ need m to work per line in multiline text; . does not match line breaks unless you turn on s; and backslashes sometimes get swallowed before reaching this page. The token explainer below shows how the engine actually reads your pattern.
- How do $1 and $<name> work in the replacement?
- The replacement string follows JavaScript String.replace rules: $& is the whole match, $1 / $2 are the first / second capture groups, $<name> is the named group, and $$ is a literal $. So a literal $ that is not followed by a reference must be written as $$.
- What is the difference between greedy and lazy matching?
- Quantifiers are greedy by default: .* eats as many characters as possible before the rest of the pattern matches. Adding ? makes them lazy (.*?), matching as few as possible. From "<a> <b>", <.*> matches the whole string, while <.*?> matches only <a> - try both here and watch the highlight.
- Will my sensitive text be uploaded?
- No. Matching, highlighting and replacing all happen in your browser's memory - this is a purely static page with no backend. Your text and pattern are only saved in your own device's localStorage so you can resume them next visit; the server never sees them.
About
Regex Lab puts a pattern box, live-highlighted test text, match/group details, a replacement preview, a token explainer and a syntax cheatsheet on one page - covering the core workflow of RegExr and regex101.
Matching is executed by the browser's native RegExp engine; the explainer and cheatsheet are static data shipped with the page. There is no backend or third-party API, your input never leaves the browser, and the UI comes in English / 简体 / 繁體。
More tools
- Text Diff & Review
- Function Grapher
- ASCII Art Generator
- World Time Difference
- Perpetual Calendar
- IP Address Lookup
Runs entirely in your browser · Native RegExp engine · Free · 中文 / 繁體 / English