Free Online Regex Tester

Test, validate, and debug regular expressions with real-time matching and detailed results.

Example Patterns

Choose from common regex patterns to test and learn

Regular Expression Pattern

Enter your regex pattern and select flags

Test String

Enter the text to test against the pattern

Matches

Found 0 matches

No matches found

Regular Expression Flags

Understanding regex flags and their usage

g(Global)

Matches all occurrences of the pattern in a string, not just the first one

Pattern: cat

Text: cat and cat

With flag: Matches both 'cat's

Without flag: Only matches first 'cat'

i(Case Insensitive)

Makes the pattern case-insensitive

Pattern: hello

Text: Hello HELLO hello

With flag: Matches all variations regardless of case

Without flag: Only matches exact 'hello'

m(Multiline)

^ and $ match the start/end of each line, not just the whole string

Pattern: ^start

Text: start start

With flag: Matches 'start' at beginning of each line

Without flag: Only matches 'start' at beginning of string

s(Dot All)

Dot (.) matches newline characters \n

Pattern: .*

Text: line1 line2

With flag: Matches entire text including newline

Without flag: Matches up to newline only

u(Unicode)

Enables Unicode support. Useful for non-ASCII characters and emoji

Pattern: \u{1F604}

Text: 😄 smile

With flag: Matches Unicode emoji

Without flag: No Unicode support

y(Sticky)

Matches only from the last index position

Pattern: \w+

Text: first second

With flag: Matches only from lastIndex

Without flag: Matches anywhere in string

Regex Cheatsheet

Quick reference for common regex patterns and usage

Character Classes

.

Any character except newline

Example: a, b, c, 1, @, etc.

\w

Word character

Example: a-z, A-Z, 0-9, _

\d

Digit

Example: 0-9

\s

Whitespace character

Example: space, tab, newline

\W

Not a word character

Example: @, #, $, etc.

\D

Not a digit

Example: anything except 0-9

\S

Not a whitespace character

Example: any visible character

Quantifiers

*

0 or more times

Example: ab* matches 'a', 'ab', 'abb', etc.

+

1 or more times

Example: ab+ matches 'ab', 'abb', but not 'a'

?

0 or 1 time

Example: ab? matches 'a' or 'ab'

{n}

Exactly n times

Example: a{3} matches 'aaa'

{n,}

n or more times

Example: a{2,} matches 'aa', 'aaa', etc.

{n,m}

Between n and m times

Example: a{2,4} matches 'aa', 'aaa', 'aaaa'

Anchors

^

Start of string/line

Example: ^hello matches 'hello world'

$

End of string/line

Example: world$ matches 'hello world'

\b

Word boundary

Example: \bcat\b matches 'cat' but not 'category'

\B

Not a word boundary

Example: \Bcat\B matches 'category' but not 'cat'

Groups & Assertions

(abc)

Capturing group

Example: (\w+)@(\w+\.\w+) captures username and domain

(?:abc)

Non-capturing group

Example: (?:https?://) matches protocol without capturing

a(?=b)

Positive lookahead

Example: a(?=b) matches 'a' only if followed by 'b'

a(?!b)

Negative lookahead

Example: a(?!b) matches 'a' only if not followed by 'b'

Common Patterns

Email
^[\w.-]+@([\w-]+\.)+[\w-]{2,}$

Basic email validation

URL
https?:\/\/[\w\d\-._~:/?#[\]@!$&'()*+,;=]+

Basic URL validation

Phone Number
\+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}

International phone number

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

At least 8 characters, upper, lower, number, special

Features

Our Regex Tester tool provides comprehensive features for testing and debugging regular expressions.

Real-Time Testing

Test your regex patterns instantly with live highlighting of matches as you type.

Regex Flags Support

Use standard regex flags (g, i, m, s, u, y) to modify pattern matching behavior.

Match Details

View detailed information about matches, including indices and captured groups.

Easy Export

Copy or download match results for further analysis or documentation.

Match Navigation

Navigate through multiple matches easily with next/previous controls.

Syntax Validation

Instant feedback on regex syntax errors to help debug patterns.

How to Use the Regex Tester

Step 1

Enter your regular expression pattern in the pattern field and select appropriate flags (g, i, m, etc.).

Step 2

Type or paste your test text in the input area. Matches will be highlighted in real-time.

Step 3

View match details, navigate through matches, and use copy/download options for results.

Frequently Asked Questions