T
ToolboxKit

Regex Tester

Online regex tester that highlights matches in real time. See capture groups, match details, and use common pattern presets.

Ad
Ad

About Regex Tester

The Regex Tester is an interactive tool for building, testing, and debugging regular expressions in real time. As you type your pattern and test string, matches are instantly highlighted in the text, giving you immediate visual feedback on whether your regex works as intended.

Supported Flags

The tool supports all standard JavaScript regex flags. The global flag (g) finds every match in the input rather than stopping at the first one. The case-insensitive flag (i) makes the pattern match regardless of letter case. The multiline flag (m) changes the behavior of ^ and $ to match the start and end of each line rather than the entire string. The dotAll flag (s) makes the dot character match newline characters as well.

Match Details and Capture Groups

For each match found, the tool displays detailed information including the full match text, its position (start and end index) in the input string, and any capture groups defined by parentheses in your pattern. This makes it easy to verify that your groups are extracting the correct substrings.

Pattern Presets

A library of common regex patterns is available as quick-select presets. These include patterns for email addresses, URLs, IP addresses, dates, phone numbers, and more. Selecting a preset populates the pattern field and provides a sample test string, giving you a working starting point that you can customize for your specific needs.

The tool handles regex compilation errors gracefully, displaying clear error messages when your pattern contains syntax errors. For simple text matching without regex, the find and replace tool may be quicker. All processing happens entirely in your browser using JavaScript's native RegExp engine, so your test data never leaves your machine.

Frequently Asked Questions

What regex flags are supported?

This tool supports four standard JavaScript regex flags: g (global, find all matches), i (case-insensitive matching), m (multiline, where ^ and $ match line boundaries), and s (dotAll, where the dot matches newline characters). You can combine multiple flags by checking their respective boxes.

What are capture groups and how do I use them?

Capture groups are portions of a regex pattern enclosed in parentheses. They extract specific parts of a match for individual use. For example, the pattern (\d{3})-(\d{4}) applied to 555-1234 creates two groups containing 555 and 1234 respectively. This tool displays all groups for each match.

Why does my regex work differently here than in my programming language?

This tool uses JavaScript's built-in RegExp engine. While most basic regex syntax is universal, advanced features like lookbehind assertions, atomic groups, and possessive quantifiers may behave differently or be unavailable compared to engines like PCRE (PHP/Python) or .NET regex.

How do I match special characters literally?

Characters with special meaning in regex (such as . * + ? ^ $ { } [ ] ( ) | \) must be escaped with a backslash to match literally. For example, use \. to match a period, \( to match an opening parenthesis, and \\ to match a backslash.