Regex Tester

The Regex Tester allows you to test regular expressions against text input in real time. Regular expressions (regex) are patterns used to match character combinations in strings. They are essential for form validation, data extraction, search-and-replace operations, and text processing. This tester supports JavaScript regex syntax, shows all matches highlighted, and displays capture groups. It is perfect for debugging regex patterns before using them in your code.

Formula

Common regex patterns:
- . : any character
- * : zero or more
- + : one or more
- ? : zero or one
- ^ : start of string
- $ : end of string
- [abc] : character set
- (a|b) : alternation
- \d, \w, \s : digit, word, space

Example

Pattern: \d+ (matches numbers) Text: Hello 123 World 456 Matches: 123, 456 Pattern: \b\w+@\w+\.\w+\b (email) Text: Contact alice@example.com Matches: alice@example.com

How to Use

  1. Enter your regex pattern in the pattern field
  2. Enter your test text in the text field
  3. Select flags (global, case-insensitive, multiline)
  4. View highlighted matches in real time
  5. Check capture groups in the results panel

Frequently Asked Questions

What regex syntax does this tester use?

This tester uses JavaScript regex syntax (same as in browsers and Node.js). Most patterns are compatible with Python, Java, and other languages, but there are minor differences in advanced features like lookbehind and Unicode properties.

How do I test for case-insensitive matching?

Add the 'i' flag to your pattern. In JavaScript: /pattern/i. In this tester, check the case-insensitive option. This makes the pattern match both uppercase and lowercase versions of your text.

What are capture groups?

Capture groups are parts of your regex enclosed in parentheses. They allow you to extract specific parts of a match. For example, (\d+)-(\d+) on '123-456' creates two groups: '123' and '456'. Groups are numbered from left to right.

What is the difference between greedy and lazy matching?

Greedy matching (default) matches as much as possible. Lazy matching (add ? after a quantifier) matches as little as possible. For example, a.*b on 'axxbxxb' matches 'axxbxxb' (greedy) or 'axxb' (lazy with a.*?b).

Can I use this regex in Python or Java?

Most basic patterns work across all languages. However, advanced features differ: JavaScript does not support lookbehind before ES2018, Python uses different syntax for some features, and Java has its own Unicode handling. Always test in your target environment.