Regex Tester
Test regular expressions against text. Supports flags (g, i, m, s), shows matches, capture groups, named groups and match indexes. Runs entirely in your browser.
Regex Input
Enter a JavaScript regex pattern without forward slashes. Flags are set via checkboxes below.
Enter the text to test the regex against.
Matches
Enter a regex pattern and test text, then click Test Regex to see matches here.
Regex Cheatsheet & Common Patterns
Character Classes
| Pattern | Matches |
|---|---|
. | Any character except newline (or any with s flag) |
\d | Digit [0-9] |
\D | Non-digit [^0-9] |
\w | Word char [A-Za-z0-9_] |
\W | Non-word char [^A-Za-z0-9_] |
\s | Whitespace (space, tab, newline) |
\S | Non-whitespace |
[abc] | Any of a, b, or c |
[^abc] | Not a, b, or c |
[a-z] | Range a through z |
Anchors & Boundaries
| Pattern | Matches |
|---|---|
^ | Start of string (or line with m) |
$ | End of string (or line with m) |
\b | Word boundary |
\B | Non-word boundary |
\A | Start of string (ignores m) |
\z | End of string (ignores m) |
Quantifiers
| Pattern | Meaning |
|---|---|
* | 0 or more (greedy) |
+ | 1 or more (greedy) |
? | 0 or 1 (greedy) |
{n} | Exactly n times |
{n,} | n or more |
{n,m} | n to m times |
*? | 0 or more (lazy) |
+? | 1 or more (lazy) |
?? | 0 or 1 (lazy) |
Common Patterns
| Pattern | Matches |
|---|---|
^[\w.+-]+@[\w-]+\.[\w.-]+$ | Email (basic) |
https?://[^\s]+ | URL |
\b\d{1,3}(\.\d{1,3}){3}\b | IPv4 address |
^\d{4}-\d{2}-\d{2}$ | ISO date (YYYY-MM-DD) |
\b[A-Fa-f0-9]{6}\b | Hex color (6-digit) |
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$ | Password (8+, upper, lower, digit) |
Click any pattern to load it into the tester above.
Technical Deep Dive: Flags & Capture Groups
The g flag (Global)
Without g, RegExp.exec() returns only the first match. With g, it finds all matches and updates lastIndex for iterative searching.
const re = /ab/g;
const str = "ab ab ab";
re.exec(str); // ["ab"], lastIndex = 2
re.exec(str); // ["ab"], lastIndex = 5
re.exec(str); // ["ab"], lastIndex = 8
re.exec(str); // null, lastIndex = 0
The i flag (Case-Insensitive)
Makes matching case-insensitive. Works with Unicode when combined with the u flag (not currently exposed in this tool).
/pattern/i.test("PATTERN"); // true
/pattern/i.test("PaTtErN"); // true
/pattern/i.test("nope"); // false
The m flag (Multiline)
Changes ^ and $ to match start/end of each line instead of start/end of string. Useful for multi-line input.
const str = "line1
line2
line3";
/^line/m.test(str); // true (line1)
/^line2/m.test(str); // true (line2)
/line$/m.test(str); // true (line3)
The s flag (dotAll)
Makes . match any character including newlines. Without s, . stops at line breaks.
const str = "a
b
c";
/a.c/.test(str); // false (newline blocks .)
/a.c/s.test(str); // true (. matches newline)
Numbered Capture Groups
Parentheses (...) create numbered capture groups. Group 0 is the full match; groups 1, 2, 3… are nested left-to-right by opening parenthesis.
const re = /(\d{4})-(\d{2})-(\d{2})/;
const match = "2024-01-15".match(re);
match[0]; // "2024-01-15" (full match)
match[1]; // "2024" (year)
match[2]; // "01" (month)
match[3]; // "15" (day)
Named Capture Groups
Use (? to name groups. Access via match.groups.name. Works with replace() for powerful templating.
const re = /(?\d{4})-(?\d{2})/;
const match = "2024-01".match(re);
match.groups.year; // "2024"
match.groups.month; // "01"
// Replace with named group reference
"2024-01".replace(re, "$/$"); // "01/2024"
Frequently Asked Questions
- No. All processing happens entirely in your browser. Your data never leaves your device.
- The tool supports the standard JavaScript regex flags: g (global), i (case-insensitive), m (multiline), and s (dotAll).
- Yes. Each match shows its numbered capture groups and any named capture groups.
- Zero-length matches are displayed at each position they occur, with safeguards to prevent infinite loops.
- The tool uses the browser's native RegExp engine. Extremely complex patterns may cause the browser to become unresponsive. There is no server-side timeout protection.
- Yes. Use the Copy Matches or Download Matches buttons to export the results as JSON.
- Once the page is loaded, the tool works offline because all logic runs client-side.
Regex Tester is a free, client-side developer tool for building, testing, and debugging regular expressions in real time. Part of DevPouch 2.0, it runs entirely in your browser, so your patterns and test strings never leave your machine — a practical choice for sensitive logs, proprietary code, or user data. Instant match highlighting, live capture-group inspection, and toggleable flags (g, i, m, s, u) let you refine expressions with confidence before shipping them to production. There is no sign-up, no server round-trip, and no latency: just type, test, and copy.
Key features include real-time match highlighting as you type, a capture-group viewer that breaks out every matched subgroup, and flag toggles for global, case-insensitive, multiline, dotall, and unicode modes. You can save and share patterns, download match results, and test against large input strings without performance hiccups. Every operation executes in the browser, keeping your data private and your workflow fast.
Use Cases
Use the Regex Tester to validate form inputs including email addresses, phone numbers, passwords, and URLs. Extract structured data from server logs, HTML markup, or plain-text exports. Run search-and-refactor operations across large codebases, sanitize user-generated content, and reduce injection risk. It also serves as a hands-on sandbox for learning regex syntax, with immediate visual feedback that helps developers at every skill level write safer, more accurate patterns.
How-To
- Enter your regular expression into the pattern field.
- Type or paste the text you want to test into the input area.
- Toggle flags such as global, case-insensitive, multiline, dotall, and unicode to control matching behavior.
- Watch matches highlight instantly and inspect each capture group for detailed results.
- Copy the matches or export the results for use in your application code.
Because evaluation happens locally in your browser, there is no risk of leaking private data to a remote service, and you can work offline once the page is loaded. Use it during code review, while writing input validators, or when auditing legacy parsers. Regular expressions are powerful but easy to mistype; a dedicated tester catches errors before they reach production. Bookmark the Regex Tester in DevPouch 2.0 and turn regex debugging from a guessing game into a repeatable, reliable part of your daily development workflow.