← Back to ResearchRanked

Regex Lab

Live highlighting · Group details · Replace preview · Cheatsheet

English 简体 繁體

Regular expression

/ /

Test string

Match details

Hover or click an entry to locate it in the text above

Replacement

In the replacement string use $1 / $2 for capture groups, $& for the whole match, $<name> for a named group.


  

Pattern explanation

A token-by-token walkthrough of the current pattern

Syntax cheatsheet

Click an item to insert it at the cursor

Ready-made patterns

One click loads the pattern, flags and a matching sample text.

Features

How to use

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

Runs entirely in your browser · Native RegExp engine · Free · 中文 / 繁體 / English