🔍 Regex Tester

🌍 Used by 50,000+ users ⭐ 4.9/5 rating 🔒 100% Private 🚫 No Ads, No Signup
🔒
100% Free & Private
No ads, no signup, no watermark. Everything runs locally in your browser. Your data never leaves your device.
🚩
Flag Support
Supports g, i, m, s, u flags with visual toggle and flexible combinations
📊
Match Details
Shows position index, capture groups and other detailed info for each match
📋
Common Templates
Built-in regex templates for phone, email, URL and more, one-click to use
✏️ Regular Expression
/ / g
📌 Common Regex Patterns
📝 Test Text
Match Results
Highlight Display
Matches will be highlighted here...
Match List
Matches:0 Groups:0
💻 Code Generation
JavaScript

                
📖 Introduction to Regular Expressions

Regular Expression (regex or regexp) is a pattern used to match character combinations in strings. It consists of a sequence of characters and special characters that describe a search pattern.

Regular expressions are widely used in:

  • Text search and replace - Find and replace content in text editors
  • Data validation - Validate email, phone, ID card formats
  • Data extraction - Extract specific patterns from text
  • Lexical analysis - Used in compilers and interpreters

A simple example: regex \d+ matches one or more digits, like "123" or "4567".

Basic components of regular expressions:

  • Literal characters - Match themselves, e.g., a matches "a"
  • Metacharacters - Special meaning characters like ., *, +
  • Character classes - Character sets in brackets like [a-z]
  • Quantifiers - Specify match count like {2,4} for 2 to 4 times
  • Groups and captures - Group expressions with parentheses like (abc)+
🔤 Metacharacter List
Metachar Description Example
.Matches any single character except newlinea.c matches "abc", "a1c"
^Matches start of string^Hello matches strings starting with "Hello"
$Matches end of stringworld$ matches strings ending with "world"
*Matches preceding element zero or more timesab*c matches "ac", "abc", "abbc"
+Matches preceding element one or more timesab+c matches "abc", "abbc", not "ac"
?Matches preceding element zero or one timecolou?r matches "color" or "colour"
\dMatches any digit, same as [0-9]\d+ matches "123"
\DMatches any non-digit character\D+ matches "abc"
\wMatches word characters (letters, digits, underscore)\w+ matches "hello_123"
\WMatches non-word characters\W matches "@", "#"
\sMatches any whitespace character\s+ matches spaces, tabs
\SMatches any non-whitespace character\S+ matches "hello"
\bMatches word boundary\bword\b matches exact "word"
[...]Character class, matches any char in brackets[aeiou] matches any vowel
[^...]Negated class, matches chars not in brackets[^0-9] matches non-digit
(...)Capturing group(\d+)-(\d+) captures two digit groups
(?:...)Non-capturing group(?:ab)+ matches but doesn't capture
|Alternation, matches left or right expressioncat|dog matches "cat" or "dog"
{n}Matches exactly n times\d{4} matches 4 digits
{n,}Matches at least n times\d{2,} matches 2+ digits
{n,m}Matches between n and m times\d{2,4} matches 2 to 4 digits
🚩 Flags Reference
Flag Name Description
gglobalGlobal match, find all matches instead of stopping after first
iignoreCaseCase-insensitive matching
mmultilineMultiline mode, ^ and $ match start/end of each line
sdotAllSingle line mode, makes . match newline characters
uunicodeEnable Unicode matching mode
ystickySticky matching, only match from lastIndex position

❓ FAQ

What is a regular expression?

A regular expression is a pattern matching syntax used to search, validate, and replace text. It consists of ordinary characters and special characters (metacharacters) that can describe complex text patterns, widely used in data validation, text search, and string processing.

What do the g, i, m flags mean?

g (global) enables global matching, finding all matches instead of stopping after the first; i (ignoreCase) enables case-insensitive matching; m (multiline) enables multiline mode where ^ and $ match the start and end of each line.

How to match Chinese characters?

Use [\u4e00-\u9fa5] to match common Chinese characters. This range covers all Chinese characters in the CJK Unified Ideographs basic block.

Why are my match results different from expected?

Common reasons include: 1. Special characters not escaped (. * + need backslash); 2. Greedy matching captures too much (use ? for non-greedy); 3. Incorrect flags (missing global flag returns only first result); 4. Boundary conditions not considered (^ $ usage).

Which regex syntax is supported?

This tool uses JavaScript regular expression syntax (ECMAScript specification). It supports common metacharacters, character classes, quantifiers, groups, assertions, and flags like g, i, m, s, u.

Is this tool really free with no ads?

Yes, 100% free with no ads, no registration, no watermark, and no usage limits. All processing happens locally in your browser — your data is never uploaded to any server.