Preparing your generator page
We are loading content and tools so everything is ready to use.
We are loading content and tools so everything is ready to use.
Test a JavaScript regular expression as you type. The page opens on an email pattern, the flag i, and the text hello@example.com, which matches. URL, phone, and username are the other presets. Copy wraps the source as /pattern/flags. The check uses the browser’s RegExp, and the presets are not a full email or URL standard.
More helpers are in Utility tools.
Last updated: October 8, 2026 · Published: 2026-04-09 · Updated: 2026-10-08
Regex output
/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/i
Match result: Matched
Tip: start with a preset and then edit gradually. Small regex changes can create big behavior differences.
It keeps a pattern and a flag string, builds new RegExp(pattern, flags), and runs test on the text box. A successful compile shows Matched or No match. A bad pattern or a bad flag string shows the JavaScript error in red.
The pattern box is the source only. The green output adds slashes and the flags. Every preset is anchored with ^ and $, so the test text has to match from the first character through the last.
Typing in the pattern box selects Custom. The flags and the test text stay put when you change presets. An empty pattern is valid and matches whatever is in the test box, including an empty test.
Four steps. The match line follows each edit.
The pattern, the flag i, and hello@example.com are already filled in. That test matches.
URL, Phone, and Username replace the pattern. Typing in the box switches the selection to Custom.
The result uses the browser’s RegExp.test. An invalid pattern shows the engine’s error instead.
Copy regex copies /pattern/flags, including the slashes and the current flags.
What the form does before you change a field.
| Setting | This generator |
|---|---|
| Engine | The browser’s JavaScript RegExp |
| Default preset | Email, flag i, test hello@example.com |
| Default result | Matched |
| Copied text | /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/i |
| Other presets on that test | URL, phone, and username all say No match |
| Flags kept | g i m s u y, in the order you type them |
| Invalid pattern | The error is shown, and Copy still wraps /pattern/flags |
| Empty pattern | Valid. It matches the test text, including an empty test |
| Update | Live, as you type |
| Upload | None. Pattern and test text stay in the browser |
The test text stays on hello@example.com until you replace it.
Email, URL, Phone, Username, or Custom. Changing it does not change the test text or the flags.
The source without surrounding slashes. Any edit selects Custom and is kept for when you return to Custom.
g, i, m, s, u, and y only. The box starts as i. Duplicate flags make RegExp throw.
One string, tested from start to end because every preset uses ^ and $. It starts as hello@example.com.
Matched, No match, or the JavaScript error. One test per change, not a list of matches.
The delimited literal. A slash inside a custom pattern is not escaped when the slashes are added.
The pattern box shows the source. Copy adds the slashes and whatever flags are in the flag box. With the default flag, the email literal is:
/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/i| Preset | Source | A result |
|---|---|---|
| ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$ | hello@example.com matches. a@b.c and a@localhost do not. | |
| URL | ^(https?:\/\/)?([\w-]+\.)+[\w-]{2,}(\/\S*)?$ | example.com matches. localhost and 10.0.0.1 do not. |
| Phone | ^\+?[0-9\s().-]{7,20}$ | 1234567 matches. 123456 does not. Letters do not. |
| Username | ^[a-zA-Z0-9_]{3,20}$ | abc matches. ab, dots, and hyphens do not. |
Each row uses that preset and the flag i. The email pattern allows a leading dot and a doubled dot. The URL pattern requires the final label to be at least two characters.
| Text | Preset | Result |
|---|---|---|
| hello@example.com | Matched | |
| a..b@c.com | Matched | |
| a@b.c | No match | |
| example.com | URL | Matched |
| https://example.com/a?q=1 | URL | Matched |
| http://localhost | URL | No match |
| 10.0.0.1 | URL | No match |
| 192.168.0.10 | URL | Matched |
| +1 (555) 010-8821 | Phone | Matched |
| 123456 | Phone | No match |
| abc | Username | Matched |
| user.name | Username | No match |
Short definitions for the words on this page.
One of four fixed JavaScript patterns: email, URL, phone, or username.
The copied form /pattern/flags. The pattern box itself has no surrounding slashes.
Case insensitive. It is the default flag. These presets already include both cases.
^ and $ in every preset, so the test must match the entire text box.
The pattern you typed. It is restored when you leave a preset and come back to Custom.
The email literal that matches hello@example.com, what the other presets reject, and which flags the box keeps.
Explore more tools in the directory.