Regex Tester & Builder
Highlights matches
“One accepted answer here saves a hundred people an hour each.
Test and debug regular expressions in real time — matches highlight as you type, with capture-group inspection, replace/substitution, a plain-English explainer, a click-to-insert builder, a cheatsheet, a library of 225+ ready-made patterns, and code generation for 11 languages. Runs entirely in your browser; nothing is uploaded.
Auto-example is on — the text above changes to match whatever pattern you type.
hello@example.com#1 · idx 18–35support@legitlads.com#2 · idx 39–60Regex tester — key facts
- Engine
- JavaScript / ECMAScript (matches Node & browsers)
- Real-time
- Yes — highlights as you type, no submit button
- Capture groups
- Positional ($1) & named (?<name>)
- Replace
- $1, $<name>, $& with live preview
- Code export
- 11 languages (JS, Python, PHP, Java, Go, Rust…)
- Privacy
- 100% in-browser — nothing uploaded
- Flags
- g i m s u y d
- Price
- Free, no sign-up, no ads
Regex flags
| Flag | Name | Meaning |
|---|---|---|
| g | global | Find all matches, not just the first. |
| i | ignore case | Case-insensitive matching. |
| m | multiline | ^ and $ match start/end of each line. |
| s | dotall | . also matches newline characters. |
| u | unicode | Treat the pattern as a sequence of Unicode code points. |
| y | sticky | Match only from lastIndex (anchored search). |
| d | indices | Expose start/end indices of captured groups. |
Regex syntax cheatsheet
Anchors
^Start of string / line$End of string / line\bWord boundary\BNot a word boundaryCharacter classes
.Any character (except newline)\dDigit (0–9)\wWord char (a–z, 0–9, _)\sWhitespace\D \W \SNegated versions[abc]Any of a, b, c[^abc]Not a, b or c[a-z]Range a to zQuantifiers
*0 or more+1 or more?0 or 1 (optional){n}Exactly n{n,}n or more{n,m}Between n and m*? +?Lazy (shortest match)Groups & lookarounds
(…)Capturing group(?:…)Non-capturing group(?<name>…)Named group(?=…)Positive lookahead(?!…)Negative lookahead(?<=…)Positive lookbehind(?<!…)Negative lookbehinda|bAlternation (a or b)What is a regular expression?
A regular expression (regex) is a compact pattern that describes a set of strings. Developers use regex to search, validate, extract and replace text — checking an email address, pulling every URL out of a log, reformatting dates, or find-and-replace across a codebase. A pattern is built from literal characters plus metacharacters like \d (a digit), + (one or more) and ( ) (a capture group).
This tester uses the JavaScript / ECMAScript engine, so what you see here behaves exactly like regex in Node.js and the browser. Use the Explain tab to break any pattern down into plain English, the Library tab for battle-tested patterns, and the Code tab to export to your language.
Common regex patterns (ready to use)
Click any pattern in the Library tab to load it with sample text. Here are the most-searched ones:
| Use case | Pattern |
|---|---|
/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g | |
| URL | /https?://[^\s/$.?#].[^\s]*/gi |
| IPv4 address | /\b(?:\d{1,3}\.){3}\d{1,3}\b/g |
| Phone (intl) | /\+?\d{1,3}[\s-]?\(?\d{1,4}\)?[\s-]?\d{3,4}[\s-]?\d{3,4}/g |
| Date (YYYY-MM-DD) | /\b\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])\b/g |
| Hex colour | /#(?:[0-9a-fA-F]{3}){1,2}\b/g |
| Strong password | /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).{8,}$/ |
| Username (3–16) | /^[a-zA-Z0-9_]{3,16}$/ |
| Slug | /^[a-z0-9]+(?:-[a-z0-9]+)*$/ |
| Hashtag | /#\w+/g |
| HTML tag | /<([a-z]+)(?:[^>]*)>(.*?)</\1>/gi |
| Credit card | /\b(?:\d[ -]*?){13,16}\b/g |
225+ regex patterns, organised
Open the Library tab in the tester to search and load any of these with one click — each comes with sample text so you can see it match instantly. A taste of what's inside:
Web & Network
19Email Address · International Email · URL · URI · Domain Name · Subdomain …
Identity & Government
7SSN · Aadhaar Number · PAN Number · GSTIN · Passport Number · Driving License Number …
Finance & Payments
9Credit Card Number · Debit Card Number · CVV · IBAN · SWIFT/BIC Code · Bank Account Number …
Phone & Contact
5Phone Number · International Phone Number · Mobile Number · Landline Number · Fax Number
Dates & Times
8Date (DD/MM/YYYY) · Date (MM/DD/YYYY) · ISO Date · Time (12 Hour) · Time (24 Hour) · DateTime ISO8601 …
Colors
7Hex Color · RGB Color · RGBA Color · HSL Color · HSLA Color · CMYK Color …
Numbers
11Hexadecimal Number · Binary Number · Octal Number · Decimal Number · Integer · Positive Integer …
IDs, Hashes & Tokens
14UUID v1 · UUID v4 · UUID v7 · ULID · NanoID · MD5 Hash …
Encoding & Data
5Base64 String · Base64URL String · Data URI · Unicode Escape Sequence · Environment Variable
Markup & Data Formats
16HTML Tag · HTML Attribute · HTML Comment · XML Tag · XML Attribute · XML Comment …
Databases & Queries
5SQL SELECT Statement · SQL INSERT Statement · SQL UPDATE Statement · SQL DELETE Statement · SQL Identifier
Programming & Naming
13CSS Selector · CSS Unit · JavaScript Identifier · Python Identifier · Variable Name · Function Name …
Files & Paths
8File Name · File Extension · File Path · Windows Path · Linux Path · UNC Path …
Media & Repo URLs
7Image URL · Video URL · Audio URL · YouTube URL · Vimeo URL · GitHub URL …
Codes & Standards
10Semantic Version (SemVer) · Version Number · ISBN-10 · ISBN-13 · ISBN · ISSN …
Geo & Address
11Latitude · Longitude · GPS Coordinates · GeoJSON · Street Address · City Name …
Logistics & Vehicles
6Vehicle Registration Number · VIN · License Plate · Airline Flight Number · Tracking Number · Container Number
Text & Characters
20Emoji · Unicode Character · ASCII Character · Whitespace · Newline · Tab Character …
Usernames & Passwords
2Username · Password Strength
Social & Handles
7Hashtag · Mention (@username) · Discord Tag · Telegram Username · Slack Channel · Reddit Username …
Crypto & Blockchain
6Bitcoin Address · Ethereum Address · Litecoin Address · Solana Address · Wallet Address · Cryptocurrency Transaction Hash
DevOps & Infra
8Log Entry · Apache Log · Nginx Log · Operating System Version · Stack Trace · Docker Image Tag …
Security & Certificates
8PEM Certificate · Public Key · Private Key · CSR · X.509 Certificate · LDAP DN …
Regex Meta
13Regex Pattern · Regex Capture Group · Regex Named Group · Regex Lookahead · Regex Lookbehind · Regex Backreference …
Regex tester for every language
Build and debug your pattern here against the JavaScript engine, then open the Code tab to export a ready-to-paste snippet for your stack. We generate idiomatic code for 11 languages:
Note: flavours differ slightly — Python uses re, PHP uses preg_match, Java uses Pattern, and Go/Rust use RE2 (no lookarounds/backreferences). The Code tab maps flags to each language's equivalent automatically.
Frequently Asked Questions
How do I test a regular expression?+
Type your pattern into the field at the top, toggle any flags (g, i, m, s…), and paste your text into the test area. Matches highlight live as you type — there is no run button. Each match, its position and capture groups appear in the Matches tab instantly.
Why is there no submit button?+
The tester is fully reactive: it re-evaluates your pattern against the test string on every keystroke and highlights matches in real time. That makes debugging far faster than a submit-and-wait flow.
Which regex flavour does it use?+
It runs the native JavaScript (ECMAScript) regex engine in your browser, so behaviour matches Node.js and every modern browser exactly. The Code tab then translates your pattern into Python, PHP, Java, C#, Go, Ruby, Rust, Perl and grep syntax.
What do the flags g, i, m, s, u, y mean?+
g = global (all matches), i = case-insensitive, m = multiline (^ and $ per line), s = dotall (. matches newlines), u = unicode, y = sticky, d = match indices. Hover each flag button for a tooltip.
How do capture groups and named groups work?+
Wrap part of a pattern in ( ) to capture it; each match lists its groups as $1, $2… Use (?<name>…) for named groups, which appear as «name». In the Replace tab you can reference them with $1 or $<name>.
Can I replace or substitute text with regex?+
Yes — open the Replace tab and enter a replacement string. It supports $1, $<name>, $& (whole match) and more, and shows the substituted result live with a count of replacements.
Is my data sent to a server?+
No. All matching, replacing and code generation happen entirely in your browser. Nothing you type is uploaded, so it is safe for sensitive text.
What is catastrophic backtracking?+
Some patterns (e.g. nested quantifiers like (a+)+) can take exponential time on certain inputs, freezing the engine. The tester caps iterations to stay responsive — if a pattern feels slow, simplify nested quantifiers or make them possessive/atomic in engines that support it.
How do I write a regex to match an email address?+
A practical pattern is [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} — one or more name characters, an @, a domain, a dot and a 2+ letter TLD. Load it from the Library tab and tweak it live. For strict RFC validation, prefer a dedicated validator.
How do I extract all numbers from text with regex?+
Use \d+ with the global flag to grab every run of digits, or -?\d+(?:\.\d+)? to also catch negatives and decimals. Paste your text and the Matches tab lists every number it finds.
Is this a good free alternative to regex101 or RegExr?+
Yes — it gives you the essentials (live highlighting, capture groups, replace, a plain-English explainer, code export and a pattern library) with no sign-up, no ads and everything running locally in your browser. It uses the JavaScript engine, so it is ideal for JS/TypeScript/Node work and for learning regex.
How do I match text across multiple lines?+
Enable the m (multiline) flag so ^ and $ match the start and end of each line, and the s (dotall) flag so . also matches newline characters. Toggle both with the flag buttons above the test area.
Why does my regex work in this tester but not in my code?+
Almost always flags or flavour. Make sure you set the same flags (g, i, m, s) in your code, and remember engines differ: this tester uses JavaScript/ECMAScript, while Python (re), PCRE/PHP, and Go/Rust (RE2, no lookbehind/backreferences) vary. The Code tab generates flag-correct snippets for each language.
How do I extract capture groups from a match?+
Wrap the parts you want in parentheses ( ). Each match then lists its groups as $1, $2…; use (?<name>…) for named groups shown as «name». In code, read them from the match array (JS), .group(n) (Python) or matcher.group(n) (Java).
What's the difference between greedy and lazy matching?+
Greedy quantifiers (*, +, {n,}) match as much as possible; adding ? makes them lazy (*?, +?) so they match as little as possible. For example, on <a><b> the pattern <.+> is greedy and matches the whole string, while <.+?> matches just <a>.
Where can I find a regex cheat sheet?+
The Reference tab is a built-in cheat sheet covering anchors, character classes, quantifiers, groups and lookarounds, and the Library tab has ready-made patterns (email, URL, IP, date, password and more) you can load and tweak live.