Test and debug JavaScript regular expressions in real-time. Regex tester with match
highlighting, explanation, and replace functionality. Free online regex debugger.
//
What is Regex?
Regular expressions (regex) are powerful patterns used for matching, searching, and
manipulating text. They provide a concise and flexible means for identifying strings
of text, such as particular characters, words, or patterns of characters. Regex is
supported in most programming languages and text editors.
Common Regex Patterns
\d - Matches any digit (0-9)
\w - Matches any word character (a-z, A-Z, 0-9, _)
\s - Matches any whitespace character
. - Matches any character except newline
^ and $ - Match start and end of string
*, +, ? - Quantifiers (0+, 1+, 0-1)
Use Cases
Form validation (email, phone, password)
Find and replace operations
Data extraction from text
Log file parsing
Input sanitization
Frequently Asked Questions
What is a regular expression (regex)?
A regular expression (regex or regexp) is a sequence of characters
that defines a search pattern. It's used for string matching, validation, and text
manipulation. Common uses include email validation, phone number formatting, and finding
patterns in text.
What regex flags are supported?
This tool supports all JavaScript regex flags: g (global - find all
matches), i (case insensitive), m (multiline - ^ and $ match line boundaries), s (dotAll
- . matches newlines), u (unicode), and y (sticky).
How do I match exact words in regex?
To match exact words, use word boundaries: \bword\b. For example,
\bcat\b matches 'cat' but not 'category' or 'educate'. The \b asserts a position between
a word character and a non-word character.
What does the regex cheat sheet include?
The cheat sheet includes common patterns like . (any character), \d
(digit), \w (word character), \s (whitespace), ^ (start of string), $ (end of string), *
(0 or more), + (1 or more), ? (0 or 1), and character classes [abc].