Back to Blog
Dev Tools6 min read

Regex Tester Complete Guide

Master regular expressions with real-time testing, ReDoS detection, and code generation. Learn regex patterns and avoid common security pitfalls.

What is a Regular Expression?

A regular expression (regex) is a sequence of characters that defines a search pattern. It's used for pattern matching, validation, and text manipulation in programming.

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

Example: Email validation pattern matching [email protected] format

Essential Regex Patterns

PatternMeaningExample
\dAny digit (0-9)Matches: 5, 9, 0
\wWord character (a-z, A-Z, 0-9, _)Matches: a, Z, _
\sWhitespaceMatches: space, tab
.Any character (except newline)Matches: a, 1, @
^Start of string/line^Hello matches "Hello world"
$End of string/lineworld$ matches "Hello world"
[abc]Character setMatches: a, b, or c

Quantifiers

*

Zero or more

a* matches "", "a", "aaa"

+

One or more

a+ matches "a", "aaa"

?

Zero or one (optional)

colou?r matches "color", "colour"

{n}

Exactly n times

\d{3} matches "123"

{n,}

n or more times

\d{2,} matches "12", "123456"

{n,m}

Between n and m times

\d{2,4} matches "12", "1234"

Regex Flags Explained

g

Global

Find all matches instead of stopping at the first match

i

Case Insensitive

Match both uppercase and lowercase letters

m

Multiline

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

s

Dotall (Single line)

. matches newline characters too

ReDoS Vulnerability Prevention

ReDoS (Regular Expression Denial of Service) occurs when a regex pattern causes catastrophic backtracking, freezing your application.

Dangerous Patterns to Avoid:

(a+)+Nested quantifiers
(a|aa)+Overlapping alternatives
(.*a){10}Greedy quantifiers in groups

Safe Alternatives:

a+Simple quantifier (no nesting)
[^a]*aNegated character class

Try Our Regex Tester

Test your patterns with real-time matching, ReDoS detection, and code generation for 6+ languages.

Open Regex Tester

Quick Reference Cheat Sheet

Character Classes

\d = [0-9]

\w = [A-Za-z0-9_]

\s = whitespace

\D, \W, \S = negated

Lookaround

(?=...) = lookahead

(?!...) = negative lookahead

(?<=...) = lookbehind

(?<!...) = negative lookbehind

Written by AI AutoSite Team • Last updated 2025-12-04