RegEx Tester
Test and debug regular expressions
No matches found
Common Patterns
What are Regular Expressions?
Regular expressions (regex or regexp) are patterns used to match character combinations in strings. They're an incredibly powerful tool for searching, validating, extracting, and replacing text. Originally developed in the 1950s, regex is now supported in virtually every programming language and text editor.
This tool uses JavaScript's regex engine, which implements the ECMAScript standard. Test your patterns here before using them in your code—all processing happens in your browser with no data sent to servers.
Regex Syntax Quick Reference
Character Classes
\d- Any digit (0-9)\w- Word character (a-z, A-Z, 0-9, _)\s- Whitespace (space, tab, newline).- Any character except newline[abc]- Any of a, b, or c[^abc]- Not a, b, or c
Quantifiers
*- 0 or more+- 1 or more?- 0 or 1 (optional){n}- Exactly n times{n,}- n or more times{n,m}- Between n and m times
Anchors & Boundaries
^- Start of string/line$- End of string/line\b- Word boundary\B- Non-word boundary
Groups & Alternation
(abc)- Capture group(?:abc)- Non-capture groupa|b- Either a or b\1- Backreference to group 1
Understanding Flags
Frequently Asked Questions
Why do I need to escape backslashes?
In JavaScript strings, backslash is an escape character. To include a literal backslash in a
regex pattern from a string, you need \\. For
example, \\d
in a string becomes \d in the
regex.
What's the difference between * and +?
* matches
zero or more occurrences (can match nothing). + requires at
least one occurrence. For example, a* matches "",
"a", "aaa", while a+ only
matches "a", "aaa".
How do I match a literal period or bracket?
Special regex characters need to be escaped with a backslash. To match a literal period, use
\.. For
brackets: \[
and \].
Characters that need escaping: . * + ? ^ $ { } [ ] \ | ( )
Why is my pattern matching too much?
Regex quantifiers are "greedy" by default—they match as much as possible. Add ? after a
quantifier for "lazy" matching (e.g., .*? instead of
.*).
Common Use Cases
- Form Validation: Validate emails, phone numbers, URLs, and custom formats
- Search & Replace: Find and transform text patterns in editors and code
- Log Parsing: Extract timestamps, IPs, and error codes from log files
- Data Extraction: Pull specific data from HTML, JSON, or unstructured text
- Input Sanitization: Remove or escape dangerous characters