Regex Tester & Debugger
Email addresses
IP addresses
Hex colors
Test and debug regular expressions in real time. See matches highlighted, capture groups extracted, and get plain English explanations.
How to Use Regex Tester & Debugger
- Enter your regular expression pattern in the pattern field.
- Set the desired flags (global, case-insensitive, multiline).
- Type or paste the test string you want to match against.
- Matches are displayed instantly with their positions and capture groups.
What is a Regular Expression?
A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. Regular expressions originated in formal language theory and were integrated into Unix text-processing tools in the 1970s. Today, they are supported in virtually every programming language, text editor, and command-line tool. A regex pattern can match simple literal text, but its real power comes from metacharacters and quantifiers that let you describe complex patterns concisely. This tool lets you write and test regex patterns against sample text in real time, showing all matches with their positions and any captured groups.
How Regular Expressions Work
A regex engine reads the pattern and builds an internal state machine that processes the input string character by character. Literal characters match themselves, while metacharacters have special meanings. The dot (.) matches any single character. Character classes like [a-z] match any character in the specified range. Quantifiers control repetition: * matches zero or more times, + matches one or more times, and ? matches zero or one time. Anchors like ^ (start of string) and $ (end of string) constrain where matches can occur. Parentheses create capture groups that extract specific portions of the matched text.
Common Use Cases
- Validating input formats such as email addresses, phone numbers, and postal codes
- Extracting data from log files, CSV content, and structured text
- Performing search-and-replace operations in text editors and code
- Parsing URLs, file paths, and command-line arguments
- Filtering and routing requests in web servers and API gateways
- Syntax highlighting and tokenization in code editors
Regex Metacharacters Reference
Here are the most commonly used regex metacharacters and their meanings. The backslash \d matches any digit (equivalent to [0-9]), \w matches any word character (letters, digits, underscore), and \s matches any whitespace character including spaces, tabs, and newlines. Their uppercase counterparts (\D, \W, \S) match the opposite. Curly braces specify exact repetition counts: {3} matches exactly three times, {2,5} matches between two and five times. The pipe | acts as an OR operator, matching the pattern on either side.
Lookahead ((?=...)) and lookbehind ((?<=...)) assertions match a position without consuming characters, which is useful for complex pattern matching. Non-capturing groups (?:...) group patterns without creating a capture. Named capture groups (?<name>...) assign labels to captured text, making patterns more readable and maintainable. When building complex patterns, start with a simple version that matches your basic cases, then refine incrementally.
Once your patterns are working, compare text outputs with our Diff Checker, or validate structured data using the JSON Validator. For text analysis, try the Word Counter.