免费在线正则表达式测试器 | Fairmont AI

在线免费测试正则表达式。实时匹配高亮显示,调试更简单。

Our free Regex Tester lets you test and debug regular expressions in real time directly in your browser. As you type your pattern, matches are instantly highlighted in the test string. Full flag support (g, i, m, s) is included, along with a match list showing each match, its index, and captured groups. Quick-pattern buttons let you load common patterns like email, URL, and IP address regex instantly.

How to Test a Regular Expression

  1. Enter Your Pattern: Type your regular expression pattern in the pattern field (without slashes — just the pattern itself). Use Quick Patterns to load common examples.
  2. Select Flags: Choose which flags to apply: g (global/find all), i (case insensitive), m (multiline), or s (dot matches newlines).
  3. See Matches in Real Time: Type or paste your test string and see all matches highlighted instantly. The match list shows each match, its position, and any captured groups.

Frequently Asked Questions

What regex engine does this use?

This tester uses JavaScript's built-in RegExp engine, which is ECMAScript-compliant. It supports standard regex syntax including lookaheads (in modern browsers).

What does the 'g' flag do?

The global (g) flag makes the regex find ALL matches in the string rather than stopping at the first one. Without g, only the first match is returned.

What does the 'i' flag do?

The case insensitive (i) flag makes the pattern match regardless of letter case. For example, /hello/i matches 'Hello', 'HELLO', and 'hello'.

How do I match a literal dot or parenthesis?

Escape special characters with a backslash: \. matches a literal dot, \( matches a literal opening parenthesis.

What are capturing groups?

Groups created with parentheses (pattern) capture the matched text separately. You can reference them in the match list under 'groups'.

Why isn't my regex matching?

Common issues: forgetting to escape special chars (., *, +, ?), wrong flags, or anchors (^ and $) behaving differently than expected. Try the i flag if case is an issue.

What is the 'm' flag?

The multiline (m) flag makes ^ match the start of each line and $ match the end of each line, rather than just the start/end of the entire string.

Is there a match limit?

For performance, the tester stops after 500 matches. For testing very large strings or patterns, you may want to use a local development environment.