Regex Tester

/ /
Flags:
Quick Examples

Matches (0)

No matches found

Highlighted Matches

Replace Result:

About Regex Tester

A regular expression (regex) is a powerful pattern-matching tool used for searching, validating, and manipulating text. This regex tester provides real-time pattern testing with match highlighting, capture group display, and replace functionality. Perfect for developers learning regex, debugging patterns, or validating data formats like emails, phone numbers, and URLs. All testing happens in your browser for complete privacy.

How to Use

  1. Enter your regex pattern in the pattern field (without the forward slashes).
  2. Select the flags you need: g (global), i (case-insensitive), m (multiline), etc.
  3. Type or paste your test text in the Test String field.
  4. View matches in real-time with highlighting and capture group details.
  5. Use the Replace Pattern field to test string replacement with your regex.
  6. Try Quick Examples to learn common regex patterns.

Frequently Asked Questions

What are regex flags?

Flags modify how the regex pattern works: g (global) finds all matches instead of just the first; i (ignore case) makes matching case-insensitive; m (multiline) makes ^ and $ match line breaks; s (dotAll) makes . match newlines; u (unicode) enables proper Unicode matching; y (sticky) matches only at lastIndex position.

What are capture groups?

Capture groups are parts of a regex pattern enclosed in parentheses ( ). They "capture" the matched text for later use. For example, in the pattern (\d{3})-(\d{3})-(\d{4}) matching "555-123-4567", Group 1 captures "555", Group 2 captures "123", and Group 3 captures "4567".

How do I use capture groups in replacement?

In the Replace Pattern field, use $1, $2, $3, etc. to reference captured groups. For example, with pattern (\w+)@(\w+) and replacement "$1 at $2", the text "john@example" becomes "john at example". The numbers correspond to the order of capture groups in your pattern.

What does the global flag (g) do?

Without the global flag, regex only finds the first match. With the global flag enabled, it finds all matches in the text. This is essential for finding multiple occurrences and for proper string replacement of all instances.

Why is my pattern not matching?

Common issues: special characters (. * + ? [ ] { } ( ) ^ $ | \) need escaping with backslash; forgetting the global flag for multiple matches; case sensitivity (try the i flag); or incorrect pattern syntax. Check the error message for hints about what went wrong.

How do I match special characters literally?

Special regex characters like . * + ? [ ] { } ( ) ^ $ | \ have special meanings. To match them literally, escape them with a backslash: \. \* \+ \? etc. For example, to match "example.com", use "example\.com" not "example.com".

What are common regex patterns?

Common patterns: \d (digit), \w (word character), \s (whitespace), . (any character), + (one or more), * (zero or more), ? (optional), {n} (exactly n times), {n,m} (between n and m times), [abc] (any of a, b, or c), [^abc] (not a, b, or c), ^ (start), $ (end).

Is my data secure?

Yes! All regex testing happens entirely in your browser using JavaScript. Your patterns and test strings are never sent to any server, ensuring complete privacy. This tool works offline once loaded.

Other Tools