Regex Tester
Runs a JavaScript regular expression on your text as you type, highlights every match and lists capture groups. It also previews replace and split, and stops runaway patterns after 1.5 seconds.
- Runs in your browser
- Nothing uploaded
- Free, no sign-up
Type the pattern without slashes, or paste a literal like /abc/gi and the flags are picked up.
| # | Match | Position | Groups |
|---|
How to Use Regex Tester
- Type the pattern. Write it without slashes, or paste a literal like /abc/gi and the flags are picked up.
- Switch flags on or off. g finds every match, i ignores case, m makes ^ and $ work per line, s lets the dot match line breaks.
- Paste your test text. Matches are highlighted and listed with their positions and groups.
- Use the tabs. Replace shows the text after a replace, Split shows the parts, Code gives the regex as JavaScript.
- Share it. Copy share link gives a link that opens the tester with your pattern and text.
Example: pulling dates out of text
Press Sample. The pattern is (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) with the g flag, and the text is “Invoices dated 2026-03-14, 2026-11-02 and 2025-12-31 are due.”. The tester reports 3 matches and lists them:
| # | Match | Position | Groups |
|---|---|---|---|
| 1 | 2026-03-14 |
15 to 25 | year 2026, month 03, day 14 |
| 2 | 2026-11-02 |
27 to 37 | year 2026, month 11, day 02 |
| 3 | 2025-12-31 |
42 to 52 | year 2025, month 12, day 31 |
Each match also shows $1, $2 and $3, because named groups are numbered too. On the Replace tab, the replacement $<day>/$<month>/$<year> turns the text into “Invoices dated 14/03/2026, 02/11/2026 and 31/12/2025 are due.”. That is how you switch a date format in one step.
Regex cheat sheet with tested examples
Each row was run in this tester (with the g flag plus any flag shown). The last column is exactly what it matched.
| Pattern | Meaning | Text | Matches |
|---|---|---|---|
\d |
a digit | Room 42, floor 3 | 4, 2, 3 |
\w+ |
one or more word characters (letters, digits, _) | user_name-2 | user_name, 2 |
\s+ |
one or more whitespace characters | a, two spaces, b, a tab, c | two spaces, a tab |
\bcat\b |
cat as a whole word | cat concat cat. | cat, cat |
colou?r |
u is optional | color colour | color, colour |
\d{3,4} |
3 or 4 digits | 12 123 12345 | 123, 1234 |
[aeiou] with i |
one vowel (i flag: any case) | Regex | e, e |
[^0-9]+ |
one or more characters that are not digits | ab12cd | ab, cd |
^\w+ with m |
the first word on each line (m flag) | one, new line, two | one, two |
(\w+)@(\w+)\.com |
two capture groups | [email protected] | [email protected] (groups: ada, example) |
(?<user>\w+)@ |
named group “user” | [email protected] | ada@ (groups: ada) |
\d+(?=%) |
digits followed by % (lookahead) | 10% of 250 | 10 |
(?<!\$)\b\d+ |
numbers without a $ in front (lookbehind) | $30 or 45 | 45 |
<.+?> |
lazy: as little as possible | <b>bold</b> | <b>, </b> |
cat|dog |
either word | hotdog catalog | dog, cat |
Flags change how the whole pattern behaves: g finds every match instead of the first, i ignores case, m makes ^ and $ match at every line, s lets the dot match line breaks, u turns on full Unicode support such as \p{L}, v is a stricter Unicode mode with set operations, y only matches at the current position, and d reports where each group starts and ends.
How it works
- The pattern runs in your browser’s own JavaScript engine (V8 in Chrome and Edge, SpiderMonkey in Firefox, JavaScriptCore in Safari), so the result is what your JavaScript code will get.
- Matching happens in a background Web Worker. If one run takes longer than 1.5 seconds, the worker is stopped and the tester tells you the pattern is likely backtracking. Without that guard a pattern like
^(a+)+$could freeze the tab. - With the g flag the tester calls
execin a loop. After an empty match it moves forward one character (one code point with u or v) so it never loops forever. - Errors come straight from the RegExp constructor, for example “Invalid regular expression: /(abc/g: Unterminated group” or “Invalid regular expression: /a{2,1}/g: numbers out of order in {} quantifier”.
- The share link stores the pattern, flags and up to 2,000 characters of text after the # sign. Browsers do not send that part of a link to the server.
Limits
- This is JavaScript regex. Features from PCRE, Python or .NET such as possessive quantifiers, atomic groups, recursion and \A or \Z do not exist here and give an error or match literally.
- The table lists the first 500 matches and the highlight shows the first 2,000. The count keeps going up to 200,000.
- Flags your browser does not support, usually v in older browsers, are hidden.
Frequently asked questions
Which regex flavour does this tester use?
JavaScript (ECMAScript), run by the browser you are using. Most of the syntax is shared with PCRE, Python and Java, but some details differ, such as named groups written (?<name>…) and the lack of possessive quantifiers.
Why does my regex only find one match?
The g (global) flag is off. Without it, JavaScript stops at the first match, and replace only changes the first one. Turn g on and every match is found.
What does “Unterminated group” mean?
An opening bracket ( has no closing ). Count the brackets, and if you want a literal bracket, escape it as \( or \).
Why did the tester stop after 1.5 seconds?
The pattern was still running, which almost always means catastrophic backtracking. A nested quantifier such as (a+)+ or (\w*)* can try an exponential number of ways to match text that almost fits. Remove the nesting or make the inner part more specific.
Do ^ and $ match at every line?
Only with the m (multiline) flag. Without it, ^ means the start of the whole text and $ the end. In the cheat sheet, ^\w+ with m matches both “one” and “two” on separate lines.
Related Tools
Regex Cheat Sheet →
A searchable quick reference for regular expression tokens, with what each one matches.
Regex Generator →
Builds a regular expression from example text you paste, checks it against examples that…
Email Subject Line Tester →
Score email subject lines - length, spam triggers, emoji count, inbox preview. Tips to…
Structured Data Tester →
Paste JSON-LD or page HTML and validate it against required and recommended properties per…
AI Token Counter →
Count the tokens in your text and estimate the API cost across GPT, Claude…
Android AssetLinks JSON Generator - App Links →
Android AssetLinks JSON Generator files for Android App Links. Configure package names and SHA-256…
Convert ASCII to Binary →
Convert ASCII to Binary tool. Convert text to binary and binary to text. 100%…
Base32 Encoder/Decoder →
Free Base32 encoder and decoder tool. Encode or decode Base32 strings online. 100% client-side,…
Base58 Encoder/Decoder →
Free Base58 encoder and decoder tool. Encode or decode Base58 strings like Bitcoin addresses.…
Base64 Encoder and Decoder →
This tool turns text or any file into Base64, a string of letters, digits…
BBCode to HTML Converter →
Generate standard semantic HTML arrays translating classic forum BBCode syntax cleanly explicitly mappings independently…
Convert Binary to Hex →
Converts binary to hexadecimal and back, for one value or a whole list. It…