Regex Tester
Test, debug, and validate your JavaScript regular expressions in real-time. Perfect for checking email validation, URL parsing, and password strength patterns.
/
/gu
Match Result
| # | Match | Index | Groups |
|---|---|---|---|
| 1 | Hello | 0 | $1: H |
| 2 | World | 6 | $1: W |
| 3 | Gemini | 17 | $1: G |
| 4 | CLI | 24 | $1: C |
| 5 | This | 29 | $1: T |
| 6 | Test | 39 | $1: T |
History
Saved patterns will appear here.
Cheatsheet
Common Regex Questions
How to validate an email address with Regex?
A simple pattern is ^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$. Paste this above to test it against your email list.
Select file extension only?
Use \.[0-9a-z]+$ to match the extension at the end of a string. Useful for filtering file types.
Check for minimum 8 characters, at least one letter and one number?
Use lookaheads: ^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$. This is a standard strength check for passwords.
Why is my regex matching too much?
You might be using 'greedy' quantifiers like .*. Try making it 'lazy' by adding a question mark: .*?.
Match IPv4 Address?
Use ^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$ to validate standard IP addresses.
Match Date format YYYY-MM-DD?
Use ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$ to check for valid ISO dates.
Match Hex Color Code?
Use ^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$ to match standard hex colors (e.g., #fff or #000000).
Validate Username (Alphanumeric, 3-16 chars)?
Use ^[a-z0-9_-]{3,16}$ if you want to allow lowercase letters, numbers, underscores, and hyphens.
Match URL (http/https)?
Use https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*) for standard web addresses.
Match HTML Tags?
Use <\/?([a-z][a-z0-9]*)\b[^>]*> to find opening and closing HTML tags (note: parsing HTML with regex is generally fragile).
Match URL Slug?
Use ^[a-z0-9]+(?:-[a-z0-9]+)*$ to validate URL-friendly slugs (e.g., this-is-a-slug).
Match Time (24 Hour Format)?
Use ^([01]\d|2[0-3]):?([0-5]\d)$ to validate HH:MM time strings.