~/dev-multi-tool > regex-tester
한국어 GitHub

Regex Tester

pattern — regex-tester
//g
Flags:
test string — regex-tester
>
matches — regex-tester
// matches will appear here

→ Related Tools

You might also need:

## What is Regex Tester?

Regex Tester is a free online tool that lets you test regular expressions against any string in real-time. See matches highlighted, capture groups extracted, and match positions displayed instantly. Perfect for debugging regex patterns, learning regular expressions, and validating text patterns.

## How to use

  1. Enter your regex pattern in the pattern field
  2. Toggle flags (global, case-insensitive, multiline, etc.)
  3. Type or paste your test string
  4. Matches are highlighted and detailed in real-time

## Common Regex Examples

### Email Address

Match standard email addresses

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

Test: user@example.com

### Phone Number (US)

Match US phone numbers with optional country code

^(\+1)?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$

Test: +1 (555) 123-4567

### URL/Website

Match HTTP and HTTPS URLs

^https?:\/\/(www\.)?[a-zA-Z0-9-]+\.[a-z]{2,}(\/.*)?$

Test: https://www.example.com/path

### IPv4 Address

Match valid IPv4 addresses

^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$

Test: 192.168.1.1

### Hexadecimal Color Code

Match 3 or 6 digit hex colors

^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$

Test: #FF5733

### Date (YYYY-MM-DD)

Match ISO date format

^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$

Test: 2026-08-28

### Username

Match alphanumeric usernames, 3-16 characters

^[a-zA-Z0-9_]{3,16}$

Test: john_doe123

### Password Strength

At least 8 chars, 1 uppercase, 1 lowercase, 1 digit, 1 special

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$

Test: MyP@ssw0rd

### Credit Card Number

Match credit card format (with optional spaces/dashes)

^\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}$

Test: 1234 5678 9012 3456

### Hashtag

Match social media hashtags

#[a-zA-Z0-9_]+

Test: #JavaScript #regex

## Regex Cheatsheet

.

Any character except newline

\d

Digit (0-9)

\D

Not a digit

\w

Word character (a-z, A-Z, 0-9, _)

\W

Not a word character

\s

Whitespace (space, tab, newline)

\S

Not whitespace

^

Start of string/line

$

End of string/line

*

0 or more repetitions

+

1 or more repetitions

?

0 or 1 repetition (optional)

{n}

Exactly n repetitions

{n,}

n or more repetitions

{n,m}

Between n and m repetitions

[abc]

Any character in set (a, b, or c)

[^abc]

Any character NOT in set

[a-z]

Character range (lowercase letters)

(abc)

Capture group

(?:abc)

Non-capturing group

a|b

Alternation (a or b)

\

Escape special character

(?=...)

Positive lookahead

(?!...)

Negative lookahead

(?<=...)

Positive lookbehind

(?<!...)

Negative lookbehind

\b

Word boundary

\B

Not a word boundary

(?<name>...)

Named capture group

## FAQ

Which regex flavor is used?

JavaScript's built-in RegExp engine. This covers most common regex features including lookahead, lookbehind, and named groups (ES2018+).

Is my data safe?

Yes. Everything runs in your browser. No data is sent to any server. All regex testing happens locally on your device.

What do the flags mean?

g = global (find all matches), i = case-insensitive, m = multiline (^ and $ match line boundaries), s = dotAll (. matches newlines), u = unicode, y = sticky (matches from lastIndex).

How do I test for literal special characters?

Escape special characters with a backslash. For example, to match a literal period use \. instead of just . which matches any character.

What's the difference between greedy and lazy matching?

Greedy (*,+,{n,}) matches as much as possible. Lazy (*?,+?,{n,}?) matches as little as possible. Example: .* is greedy, .*? is lazy.

Can I test multiline patterns?

Yes! Enable the 'm' (multiline) flag to make ^ and $ match line boundaries instead of just the start/end of the entire string.

How do capture groups work?

Use parentheses (pattern) to create a capture group. The matched text is extracted separately. Use (?:pattern) for non-capturing groups when you need grouping but not extraction.

Are lookaheads and lookbehinds supported?

Yes! Use (?=...) for positive lookahead, (?!...) for negative lookahead, (?<=...) for positive lookbehind, and (?<!...) for negative lookbehind.