Regex Tester
Test JavaScript regular expressions against any text in real time. See highlighted matches, capture groups, and match positions. Everything runs in your browser.
Uses JavaScript RegExp syntax. Matches update in real time. Processed locally in your browser.
What is a Regex Tester?
A regex tester lets you write a regular expression pattern and instantly see which parts of a text string it matches. This tool uses the native JavaScript RegExp API — the same engine used in Node.js, browsers, and most JavaScript runtimes.
How to use
- Enter a pattern in the regex input field (without surrounding
/delimiters — those are shown for context only). - Toggle flags as needed —
gfor global,ifor case-insensitive,mfor multiline, etc. - Paste test text in the text area.
- Matches appear immediately — highlighted in the text and listed in the match details panel.
Regex flags
g— Global: find all non-overlapping matches. Without this flag, only the first match is returned.i— Case-insensitive:Amatchesa.m— Multiline:^and$match at line boundaries, not just start/end of string.s— Dot-all:.matches newline characters.u— Unicode: enables full Unicode character class escapes like\p{L}.y— Sticky: matches only at the current position (lastIndex).
Examples
- Email addresses:
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} - Dates (YYYY-MM-DD):
(\d{4})-(\d{2})-(\d{2})— uses capture groups for year, month, day. - Words:
\b\w+\bwith flagg. - HTML tags:
<[^>]+> - Hex colour codes:
#[0-9a-fA-F]{6}
Regular Expression Syntax Cheatsheet
Quick lookup of essential character classes, anchors, and quantifiers supported by modern JavaScript:
| Token | Category | Description | Example |
|---|---|---|---|
. | Wildcard | Matches any single character except newline (unless s flag) | a.c matches "abc", "a-c" |
\d / \D | Digit | Matches any digit (0–9) / non-digit | \d{3} matches "123" |
\w / \W | Word | Matches alphanumeric character and underscore / non-word | \w+ matches "hello_1" |
\s / \S | Whitespace | Matches space, tab, or newline / non-whitespace | \s+ matches multiple spaces |
^ / $ | Anchor | Matches start / end of string (or line with m flag) | ^https? |
\b / \B | Boundary | Matches word boundary / non-word boundary | \bcat\b matches exact word "cat" |
* / + / ? | Quantifier | 0 or more / 1 or more / 0 or 1 optional | colou?r matches "color" or "colour" |
[a-z] / [^0-9] | Character set | Matches character in range / negated range | [A-Z] matches uppercase letter |
Capture groups
Groups defined with (…) are shown in the match detail panel as Group 1, Group 2, etc. Each group corresponds to the text captured by that parenthesised sub-expression.
Non-capturing groups (?:…) and lookaheads/lookbehinds (?=…) / (?<=…) are supported because the tool uses the full native JavaScript regex engine.
Privacy
Your regex patterns and test text are processed entirely in the browser using the native JavaScript RegExp API. No data is transmitted to any server.
Frequently Asked Questions
Why does my regex only highlight the first match?
By default in JavaScript, a RegExp halts after the first matching sequence. Enable the 'g' (global) flag to match all occurrences throughout your entire test text.
Can I test Unicode characters and emojis?
Yes. Enable the 'u' (unicode) flag so surrogate pairs, emoji sequences, and Unicode property escapes (like \p{Letter}) are properly handled as single units.
Does this tester execute eval() or unsafe code?
No. Patterns are safely constructed using the standard JavaScript RegExp constructor with syntax validation. No arbitrary code execution or eval() is used.
Is my pattern or test text uploaded anywhere?
No. All regex evaluation and syntax matching happens 100% locally in your client's web browser. No data ever leaves your device.
In-depth guides & articles
- Common Regex Patterns and Examples
A practical reference of useful regular expression patterns for digits, words, emails, dates, URLs, and more — with JavaScript-compatible examples.
- Regular Expressions Explained for Beginners
A beginner's guide to regular expressions — what they are, how the syntax works, and practical examples using JavaScript-compatible patterns.