Regex tester
Test a regular expression as you type: matches are marked in your text, each with its position and its numbered and named groups, and a replacement shows the text after replacing. Or start from a common pattern: a time, a date, an email address, a URL, an IP address, a UUID and more. It uses JavaScript's own regular expressions, as in browsers and Node.js.
Flags
- g: every match, not only the first
- i: ignore case
- m: ^ and $ match at the start and end of every line
- s: . matches line breaks too
- u: Unicode, for whole characters beyond the basic plane and classes such as \p{L} (any letter)
Quick reference
- . any character except a line break
- \d a digit, \w a letter, digit or underscore, \s white space; \D, \W and \S the opposite
- [abc] one of a, b or c; [^abc] anything else; [a-z] a range
- ^ the start, $ the end, \b a word boundary
- * 0 or more, + 1 or more, ? 0 or 1, {2,5} 2 to 5; add ? to take as few as possible
- (…) a group, $1 in a replacement; (?<name>…) a named group, $<name>; (?:…) a group that captures nothing
- a|b either a or b
- (?=…) followed by, (?!…) not followed by, (?<=…) preceded by, (?<!…) not preceded by
Common patterns
The tester has a button for each: it loads the pattern with a text to try it on, some of which matches and some, close to matching, which does not, and says what the pattern accepts and leaves out.
- Time, 24-hour (9:30, 17:45:00): /\b([01]?\d|2[0-3]):([0-5]\d)(?::([0-5]\d))?\b/g
- Time, 12-hour with AM or PM (9:30 AM, 12:15pm): /\b(1[0-2]|0?[1-9]):([0-5]\d)\s?([AaPp][Mm])\b/g
- Date, YYYY-MM-DD (2026-10-11): /\b(?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\d|3[01])\b/g
- Email address: /[\w.+-]+@[\w-]+(?:\.[\w-]+)*\.[A-Za-z]{2,}/g
- URL starting with http:// or https://: /https?:\/\/[\w-]+(?:\.[\w-]+)*(?::\d+)?(?:[\/?#]\S*[^\s.,;:!?'")\]]|[\/?#])?/g
- IPv4 address (192.168.1.20): /\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g
- UUID or GUID: /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/gi
- Hex colour code (#1e90ff, #fff): /#(?:[\da-f]{8}|[\da-f]{6}|[\da-f]{3,4})\b/gi
- Phone number, international (+14155552671): /\+[1-9]\d{6,14}\b/g
- Password with a lower-case letter, a capital and a digit, 8 characters or more: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$/gm
- Number, whole or decimal (42, -3.14): /^-?\d+(?:\.\d+)?$/gm
- Version number, semantic (1.4.2, 2.0.0-rc.1): /\bv?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([\da-z-]+(?:\.[\da-z-]+)*))?(?:\+([\da-z-]+(?:\.[\da-z-]+)*))?\b/gi
Replacements
$1, $2… put in numbered groups, $<name> a named one, $& the whole match and $$ a dollar sign. Without the g flag only the first match is replaced, as in JavaScript.
Patterns that hang
Nested repeats such as (a+)+ can take so long on text that almost matches that a program seems frozen: catastrophic backtracking. Each test here runs in the background and stops after one second, saying why.
Questions
Is this the same as PCRE, Python or Java regular expressions?
Mostly: the basics are shared, but each flavour differs at the edges. JavaScript has no possessive quantifiers or atomic groups and no \A or \Z anchors, for example. Test with the flavour your code uses.
What is the regex for a time such as 14:30?
/\b([01]?\d|2[0-3]):([0-5]\d)(?::([0-5]\d))?\b/g takes 24-hour times such as 9:30, 14:30 and 17:45:00, and turns down 24:00 and 12:60. With AM or PM: /\b(1[0-2]|0?[1-9]):([0-5]\d)\s?([AaPp][Mm])\b/g.
What is the regex for an email address?
/[\w.+-]+@[\w-]+(?:\.[\w-]+)*\.[A-Za-z]{2,}/g is a practical check: a name, @, and a domain ending in a dot and two or more letters. The standard allows more, so to know an address works, send it an email.
Is my text uploaded?
No. The pattern and the text stay in your browser and are not saved; the test runs in a worker on your own device.
More tools
- Timestamp, Cron, Regex & UUID Utilities
- Unix Timestamp Converter – Epoch to Date
- Date Format Converter – Python, Go, Java, SQL
- Cron Expression Explainer & Next Run Times
- UUID / GUID Generator & Decoder (v4, v7)
- Free Online Diagram Maker & Editor
- Formatter & Converter for JSON, YAML, XML, SQL
- Crypto Tools: Passwords, Keys, Hashes & JWTs