Regex Tester
Test regular expressions against sample text in real-time. Highlights matches and capture groups.
What is a Regex Tester?
A regular expression (regex) is a sequence of characters that defines a search pattern. Regular expressions are used in programming to find, validate, replace, or extract text based on patterns rather than exact strings. This Regex Tester lets you write a regex pattern and test it against sample text in real time — matches and capture groups are highlighted immediately as you type, with no page reloads. It uses JavaScript's built-in RegExp engine, making it ideal for testing patterns you'll use in front-end code, though the core syntax is compatible with most languages.
How to use this tool
- Enter your regular expression pattern in the Pattern field (without the surrounding slashes).
- Select your flags — g (global, find all matches), i (case-insensitive), m (multiline), s (dotAll).
- Type or paste your test string in the large text area below.
- All matches are highlighted in the test string as you type. Capture groups are shown separately.
- Use the Match info panel to inspect individual match positions and capture group values.
Common use cases
- Validating email addresses, phone numbers, or postal codes in form input fields
- Extracting structured data (dates, IPs, prices) from unstructured text or log files
- Writing find-and-replace patterns in code editors (VS Code, Sublime Text, vim)
- Building URL routing patterns in web frameworks
- Parsing log files to extract error messages, timestamps, or request paths
- Learning and experimenting with regex syntax before putting it into production code
Frequently asked questions
- Which regex flavor does this tool use?
- This tool uses JavaScript's built-in RegExp engine (ECMAScript flavor). It is compatible with patterns used in Node.js, browser JavaScript, and many other languages for common use cases, but lacks some features of PCRE (used by PHP, Python, Java) such as lookbehinds longer than fixed-width (in older engines) or named backreferences in some syntaxes.
- How do I make a regex case-insensitive?
- Enable the "i" flag using the flags selector. This makes the pattern match regardless of letter case.
- What does the "g" flag do?
- The "g" (global) flag makes the regex find all matches in the test string instead of stopping after the first one. Without "g", only the first match is returned.
- How do I match a literal dot (.) in my pattern?
- In regex, a bare dot (.) matches any character except a newline. To match a literal period, escape it with a backslash: \.
- What is a capture group?
- A capture group is a part of a regex pattern enclosed in parentheses, e.g., (\d{4}). The text matched by the group is "captured" and can be referenced separately — useful for extraction and replacement. Named groups use the syntax (?<name>pattern).