Skip to content

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

Flags

Match Result

Hello World from Gemini CLI. This is a Test string.
#MatchIndexGroups
1Hello0$1: H
2World6$1: W
3Gemini17$1: G
4CLI24$1: C
5This29$1: T
6Test39$1: T
History

Saved patterns will appear here.

Cheatsheet
Character Classes
.Any character except newline
\wWord (alphanumeric + _)
\dDigit (0-9)
\sWhitespace
[abc]Any of a, b, or c
[^abc]Not a, b, or c
Anchors
^Start of string/line
$End of string/line
\bWord boundary
Quantifiers
*0 or more
+1 or more
?0 or 1
{3}Exactly 3
{3,}3 or more
Groups
(...)Capture group
(?:...)Non-capturing group

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.