ToolzTotal
Free Tool

Regex Tester

Test and debug regular expressions with live match highlighting, capture group extraction, and a plain-English breakdown of your pattern.

Flags

0 matches

Matches

0 found
Enter a pattern and test string to see matches.

Pattern Explanation

Enter a pattern to see its token-by-token breakdown.
Common Regex Patterns

Mastering Regular Expressions: Testing, Debugging, and Structure

A regex tester is a critical sandbox tool for developers writing regular expressions. Writing a pattern to validate email formats, extract values from strings, or parse web pages is notorious for subtle bugs. This online regex tool lets you write regular expressions and test them against sample strings in real time, featuring interactive token-by-token pattern explanation and syntax-highlighted capture groups.

Understanding the Structure of Regular Expressions

Regular expressions (often shortened to regex or regexp) are sequences of characters that define a search pattern. While they can look like random letters and symbols at first glance, they follow a logical syntax. A regex pattern consists of literal characters and metacharacters (special operators like *, +, ?, ^, and $).

When you write a pattern, the browser's regex engine steps through your test text character by character. For complex patterns, we have built a **Pattern Explanation** panel that breaks down your pattern into human-readable steps. For instance, it explains that \d3 matches exactly 3 digits, while (?<name>...) defines a named capture group. This is extremely helpful for understanding, learning, and debugging complicated patterns.

Regular Expression Flags and Global Processing

Flags alter how a regular expression matches against a target text string:

  • g (Global): Instructs the regex engine to search for all matches in the text rather than stopping after finding the first one.
  • i (Case-Insensitive): Disables case matching, so [A-Z] also matches lowercase letters.
  • m (Multiline): Changes anchors ^ and $ to match the beginning and end of lines, rather than the entire input string.
  • s (dotAll): Modifies the wildcard period (.) to match newline characters as well.
  • u (Unicode): Handles characters outside the basic multilingual plane correctly.

Frequently Asked Questions

How do I test a regular expression online?
Type or paste your regular expression pattern in the Pattern input box at the top, select your flags (g for global, i for case-insensitive, etc.), then type your test string in the large text area below. Matches are highlighted in real time with a yellow background. The Results panel shows each match's index, the matched text, and any capture groups extracted from the pattern.
What regex engine does this tester use?
This regex tester uses JavaScript's built-in RegExp engine, which runs entirely in your browser. No data is sent to a server. The tool supports all standard JavaScript regex features including capture groups, non-capturing groups, lookaheads, lookbehinds, named groups, and Unicode property escapes.
How do I extract capture groups from a regex match?
Add parentheses around the parts of your pattern you want to capture — for example, (\d3) captures a three-digit number. When the pattern matches, the Results panel displays each capture group's value for every match. Named capture groups like (?<name>pattern) are also supported and shown with their group name.
What do regex flags g, i, m, s, and u do?
g (global) — find all matches rather than stopping after the first match. i (case-insensitive) — ignore letter casing. m (multiline) — ^ and $ match start/end of each line. s (dotAll) — dot matches newlines. u (unicode) — enable Unicode features and proper handling of characters outside the basic multilingual plane.
What are some common regex patterns for everyday use?
Common patterns include: Email, URL, US Phone, Date, IPv4, and Password patterns. Click any example in the cheat sheet panel above to load it instantly.
What is the difference between greedy and lazy quantifiers?
Greedy quantifiers (like * or +) match as much text as possible. Adding a question mark makes them lazy (like *? or +?), instructing the engine to match the smallest amount of text needed to satisfy the pattern. For example, matching against '<a>foo</a>' with <.*> (greedy) yields the entire string, while <.*?> (lazy) matches just '<a>'.
What are lookahead and lookbehind assertions?
Lookarounds are zero-width assertions that check if a pattern is followed or preceded by another pattern without including it in the match. Positive lookahead (?=pattern) and negative lookahead (?!pattern) look ahead, while positive lookbehind (?<=pattern) and negative lookbehind (?<!pattern) check behind.
Why did my regular expression cause a freeze (ReDoS)?

Regular Expression Denial of Service (ReDoS) occurs when a pattern with nested quantifiers (like (a+)+) experiences 'catastrophic backtracking' on strings that almost match but fail at the end. This forces the regex engine to calculate an exponential number of permutations, hanging the thread. Ensure your patterns avoid overlapping quantifiers.

How do I escape special characters in a regular expression?

Characters with special syntactic meaning in regex (like ., *, +, ?, ^, $, (, ), [, ], {, }, |, and \) must be escaped with a preceding backslash (\) if you want to match their literal characters. For example, to match a literal period, use \. rather than .

Is my test data safe when checking patterns with this tool?

Yes, completely safe. The regular expression execution is conducted purely within your web browser's local sandbox using JavaScript's RegExp class. None of your test text or regex patterns are ever sent over the network, ensuring complete privacy.

Related Tools