Regex Tester

Test regular expressions with real-time match highlighting.

/ /

Regular expressions are a compact pattern language for matching text — phone numbers, emails, log lines, dates — supported by virtually every programming language and editor. They are also notoriously easy to get wrong: one misplaced quantifier and your pattern matches too much, too little, or nothing at all.

This tester lets you write a pattern and see matches highlighted live against your sample text, with support for flags (global, case-insensitive, multiline) and capture groups. Iterating visually is the fastest way to build a correct regex before committing it to code.

How to Use This Tool

  1. Enter your regular expression pattern in the pattern field.
  2. Set flags: g (all matches), i (ignore case), m (multiline anchors).
  3. Paste sample text below — matches are highlighted instantly.
  4. Adjust the pattern until the highlights match exactly what you intend, then copy it into your code.

Frequently Asked Questions

What do the common regex tokens mean?

\d matches a digit, \w a word character, \s whitespace, . any character. Quantifiers control repetition: * means zero or more, + one or more, ? optional, {2,4} between two and four. Anchors ^ and $ pin the match to line start and end.

What is the difference between greedy and lazy matching?

Greedy quantifiers (.*) grab as much text as possible while still allowing a match; lazy ones (.*?) grab as little as possible. For extracting content between delimiters, lazy matching usually gives the expected result.

Why does my pattern work here but fail in my code?

Check two things: language differences (this tester uses JavaScript regex syntax; Python, Go and PCRE differ slightly) and string escaping — in code you often need to double backslashes, so \d becomes \\d inside a quoted string.

Copied!