Summary
A regex tester runs a regular expression against sample text and shows what it matches, so you can fix a pattern before it goes into code. To test a regex free and privately here, type the pattern into the Regular Expression Pattern box, click the flags you need, and paste text into Test String. Matches are highlighted as you type and listed with their index, length and capture groups. The pattern runs in your browser's own JavaScript engine and nothing is uploaded, as the Network tab in DevTools will show.
Because the engine is the one your browser uses for JavaScript, a pattern here is a good guide to how it will run in a web page or in Node.js, but it may not behave the same in PCRE, Python or Java; see the FAQs for the differences. Matching happens in a background worker with a 1.5-second limit, so a runaway pattern is stopped instead of freezing the tab. To apply a pattern to a whole document, use the find and replace tool, and to validate an address without writing the pattern yourself, try the email validator.
Table of Use: Patterns, Text and Results
| Goal | Pattern and flags | Test text | Result shown |
|---|---|---|---|
| Find every number | \d+g flag on (the default) | a1b22c333 | 3 matches: 1, 22 and 333. With Replace With set to #, the result is a#b#c# |
| Delete matches | \d+g flag on, Replace With left empty | a1b22c333 | abc |
| Ignore letter case | colou?rg and i flags on | Color colour COLOR colr | 3 matches; colr is not one of them |
| Reorder with named groups | (?<year>\d{4})-(?<month>\d{2})Replace With set to $<month>/$<year> | Due 2026-10 | Due 10/2026 |
| Match the start of each line | ^\w+g and m flags on | Two lines: alpha on line 1, beta on line 2 (press Enter between them) | With m: 2 matches (alpha and beta). Without m: 1 match (alpha) |
| Check the shape of an IPv4 address | Load IP Address (IPv4) from Common Patterns | host 192.168.1.1 and 999.1.1.1 | 1 match: 192.168.1.1; 999.1.1.1 is rejected |
| Trigger the safety stop | (a+)+$ | 33 a characters followed by b | Stopped after 1.5 seconds |
Features
- Six flag buttons: g (global, on by default), i (ignore case), m (multiline), s (dotAll), u (unicode) and y (sticky). Hover a button for its meaning. A syntax error is reported as soon as you type it.
- Match details: each match shows its text, index and length, plus every capture group as $1, $2 with its name if it has one. A group that did not take part is labelled "did not participate", and empty matches are marked rather than hidden.
- Replace preview: use $1, $<name> and $& in Replace With, or leave it empty to delete every match (with g on; without it only the first match is removed). Copy result copies the output.
- Explain: a token-by-token reading of the pattern in plain English, indented by group, with the active flags described underneath.
- Cheat Sheet and Common Patterns: eight reference groups (classes, quantifiers, anchors, groups, lookaround, sets, replacement and flags) and 12 ready-made patterns, including email, URL, IPv4, date, time and hex colour. Loading one replaces the pattern only; the notes there state their limits, for example that the date pattern does not check the date exists.
- Save Pattern and Share: patterns are kept in this browser's local storage; the share link carries only the pattern and flags.
Limits: it stops at 10,000 matches, highlights the first 2,000 and lists details for the first 200, and your test text is not saved between visits. It does not generate code or run other regex flavors. Tidy the code you paste the pattern into with the JavaScript beautifier, and compare two outputs with the text diff tool.
How to Use the Regex Tester
- Type your pattern into Regular Expression Pattern without the slashes, or click Sample or Common Patterns to start from an example. Click the flag buttons you need.
- Paste your text into Test String. The highlighted matches and the Matches count update as you type; scroll to Match Details for positions and groups.
- Click Explain if you want the pattern read back to you, or Cheat Sheet for syntax.
- Type a Replace With value to see the Replace Result, then click Copy result.
- Click Save Pattern to keep it in this browser, or Share to copy a link to the pattern and flags.
Other expression-style tools live nearby: build a schedule with the cron expression generator, or write Apache rewrite rules with the .htaccess generator, remembering that Apache uses PCRE rather than JavaScript syntax.
Who Can Use It
Developers writing validation or parsing code, testers building log filters, analysts cleaning exported text, and students learning regular expressions all start the same way: a pattern, some sample text and a clear picture of what matched. When your input is structured, the JSON formatter or the URL decoder may get you there without a pattern, and the duplicate line remover handles one common cleanup job directly.
FAQs
How do I test a regular expression online?
Type the pattern without its surrounding slashes into the Regular Expression Pattern box, switch on the flags you need, and paste your text into Test String. Matches are highlighted as you type, and each one is listed with its index, length and capture groups. Add a Replace With value to preview a find-and-replace on the same text.
What regex flavor does this tester use?
JavaScript (ECMAScript), run by your own browser's RegExp engine, so results match what the same pattern does in a web page or in Node.js. Named groups, lookbehind and \p{...} property escapes (with the u flag) work in current browsers. Python-style (?P<name>...) groups, and PCRE features such as possessive quantifiers and atomic groups, are not valid JavaScript.
Why does the tester say "Stopped after 1.5 seconds"?
The pattern is probably suffering catastrophic backtracking: nested or overlapping repetition such as (a+)+$ takes exponentially longer as the text grows. Matching runs in a background worker, so instead of freezing the tab the tester ends it after 1.5 seconds. Rewrite the repetition so each character can be matched only one way, for example a+ instead of (a+)+.
Why does my regex only find one match?
The g (global) flag is off. Without it, JavaScript stops after the first match and a replacement changes only that one. Click the g button next to the pattern; it is on by default here. The heading above the replace result says "first match only" whenever g is off, which is a quick way to spot it.
What is the difference between the m flag and the s flag?
The m (multiline) flag changes ^ and $ so they match at the start and end of every line instead of only the whole text. The s (dotAll) flag changes the dot so it also matches line breaks, which it normally skips. They are independent: use m to anchor per line and s when one pattern must span several lines.
How do capture groups and replacements work?
Parentheses create numbered groups ($1, $2) and (?<name>...) creates a named group ($<name>). Each match shows its groups, including ones that did not take part. In the replacement, $& inserts the whole match and $$ a literal dollar sign. With the g flag on, leave Replace With empty to see the text with every match deleted.
Is it safe to paste real data into an online regex tester?
Yes, in this regex tester nothing you type leaves your browser: matching runs in a worker on your device and the Network tab in DevTools shows no upload. Your test text is never saved. Saved patterns hold a name, the pattern, its flags, your note and the time you saved it, in this browser's local storage. Even so, avoid pasting passwords or keys into any tool you do not need to.
How do I save or share a regex?
Save Pattern stores a name, the pattern, its flags and an optional description in this browser's local storage; Load and Delete manage the list. Share copies a link containing only the pattern and flags, never your test text. They sit after the # in the address, a part that browsers do not send to any server.