liminfo

Regex Tester

Free web tool: Regex Tester

About Regex Tester

The Regex Tester is a free online tool for writing, testing, and debugging regular expressions in real time. Type a regex pattern and flags, enter your test string, and instantly see all matches highlighted directly in the text with a detailed match list showing each match value, position index, and captured groups. The tool uses the browser's native RegExp engine, so the behavior matches exactly what you would get in JavaScript.

Regular expressions are indispensable for input validation, text extraction, search-and-replace operations, log parsing, and data cleaning. Developers use regex to validate email addresses, phone numbers, and URLs; extract structured data from unstructured text; parse server logs for error patterns; and build search features with pattern matching. This tester lets you iterate on your pattern with immediate visual feedback, dramatically reducing the trial-and-error cycle.

All regex execution happens entirely in your browser. Your test strings and patterns are never transmitted to any server, making the tool safe for testing patterns against sensitive data like log files, user records, or API payloads. The tool supports all JavaScript regex flags including global (g), case-insensitive (i), multiline (m), and dotAll (s).

Key Features

  • Real-time matching that updates instantly as you type the pattern or modify the test string
  • Visual match highlighting with color-coded markers (yellow, green, blue) directly in the test string
  • Capture group display showing each parenthesized sub-match with its group number for every match
  • Full regex flag support including g (global), i (case-insensitive), m (multiline), and s (dotAll)
  • Match index reporting that shows the exact character position where each match begins in the string
  • Numbered match list displaying all matches with their values, positions, and sub-groups in an organized view
  • Instant error detection that reports invalid regex syntax with the browser engine's native error message
  • Zero-length match protection that prevents infinite loops when the pattern matches empty strings

Frequently Asked Questions

What is a regular expression (regex)?

A regular expression is a sequence of characters that defines a search pattern. It is used by programming languages, text editors, and command-line tools to find, match, extract, and replace text. For example, the pattern \d{3}-\d{4} matches phone number formats like 123-4567. Regex is supported natively in JavaScript, Python, Java, Go, PHP, Ruby, and virtually every modern programming language.

How do I use this regex tester?

Enter your regex pattern in the pattern field (without surrounding slashes), set the desired flags in the flags field (e.g., "gi" for global case-insensitive), and type or paste your test string in the textarea below. Matches are highlighted in the visualization panel and listed with their index positions and capture groups. Everything updates in real time as you type.

What are regex flags and which ones are supported?

Flags modify how the regex engine processes the pattern. This tool supports: g (global) to find all matches instead of stopping at the first, i (case-insensitive) to match regardless of letter case, m (multiline) to make ^ and $ match the start/end of each line rather than the whole string, and s (dotAll) to make the dot (.) match newline characters as well. Combine flags by typing them together, e.g., "gim".

What are capture groups and how do I see them?

Capture groups are parts of a regex pattern enclosed in parentheses (). They extract specific portions of a match. For example, (\d{3})-(\d{4}) has two capture groups: the first three digits and the last four digits. In this tool, capture groups are displayed below each match entry as "Group 1", "Group 2", etc., with their respective matched values. Use (?:...) for non-capturing groups if you need grouping without capturing.

What are common regex patterns for email and phone validation?

For basic email validation: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} matches most standard email formats. For US phone numbers: \(?\d{3}\)?[-\s.]?\d{3}[-\s.]?\d{4} handles formats like (123) 456-7890, 123-456-7890, and 123.456.7890. For Korean phone numbers: 0\d{1,2}-\d{3,4}-\d{4} matches formats like 010-1234-5678 or 02-123-4567. Note that production email validation should use proper parsing libraries rather than regex alone.

Why is my regex not matching anything?

Common reasons include: forgetting the g flag so only the first match is found, not escaping special characters (dots, brackets, parentheses need backslash escaping when used literally), using ^ or $ without the m flag in multiline text, case mismatch without the i flag, or a syntax error in the pattern which the tool will display as a red error message. Check the error output area and try simplifying the pattern to isolate the issue.

How does the match highlighting work?

The tool applies the regex to your test string using RegExp.exec() in a loop (for global flag) or a single execution. Each match is wrapped in a colored <mark> tag in the visualization panel, cycling through yellow, green, and blue for alternating matches. The surrounding non-matched text is displayed normally. The HTML output is constructed by escaping special characters and inserting highlight markers at the exact match positions.

Is my test data safe when using this regex tester?

Yes, completely. The regex engine runs natively in your browser using JavaScript's built-in RegExp object. Your patterns and test strings are never sent to any server, stored, or logged. This makes the tool safe for testing patterns against production log samples, user data, configuration files, or any other sensitive text.