Regex tester and debugger
Enter a regular expression and test text to see all matches highlighted in real time. Supports JavaScript regex syntax.
How to use regular expressions
Regular expressions (regex or regexp) are sequences of characters that define a search pattern. They are built into virtually every programming language and text editor, and are invaluable for input validation, data extraction, search-and-replace operations, and log file analysis.
This tester uses JavaScript's native regex engine. Common patterns include: [a-zA-Z] matches any letter, \d matches any digit, \s matches any whitespace, ^ anchors to start of string, $ anchors to end, + means "one or more", * means "zero or more", and ? makes the preceding element optional. Groups use parentheses () and alternatives use |.
Flags modify matching behaviour: g (global) finds all matches instead of stopping at the first, i (case-insensitive) treats uppercase and lowercase as equivalent, m (multiline) makes ^ and $ match line beginnings and ends, and s (dotAll) makes . match newlines. Common useful patterns: email addresses ([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}), URLs (https?://[^\s]+), phone numbers (\+?[\d\s\-().]{7,15}), and IPv4 addresses (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}).
Frequently asked questions
Why is this called a "Z" tool?
This tool occupies the Z slot in NameMarshal's A-Z free tools collection. Regex is one of the most universally useful developer and power-user tools available.
What regex flavour does this use?
JavaScript ECMAScript regex. Most patterns are compatible with Python, PHP, Ruby, and Java, but some syntax differences exist (e.g. lookbehind support varies).
How do I escape special characters?
Prefix with a backslash: \ to match a literal backslash, \. to match a period, \( for a parenthesis, etc. In the input field, type a single backslash, the browser's input does not need double escaping.