正则表达式测试器
Regex Tester
实时测试正则表达式,支持匹配分组高亮
Test regular expressions in real-time with match highlighting and groups
匹配结果Matches
输入正则和文本查看匹配结果Enter a pattern and text to see matches
💡 支持 JavaScript 正则语法
💡 JavaScript Regex Syntax
支持常用元字符:. \d \w \s
^ $ * + ?
[] () | 等。
点击 g 标记全局匹配,i 不区分大小写。
Supports common metacharacters: . \d \w \s
^ $ * + ?
[] () | and more.
Toggle g for global, i for case-insensitive.
How to Use This Tool
使用说明
- Enter your regular expression pattern in the regex input field.
- Add flags like
g (global), i (case-insensitive), or m (multiline) using the flag toggles.
- Type or paste your test string in the text area below.
- Matching portions are highlighted in real-time. Captured groups are displayed separately.
- Experiment with different patterns to quickly test and debug your regular expressions.
- 在正则表达式输入框中输入你的模式。
- 使用标志位切换按钮添加
g(全局匹配)、i(不区分大小写)、m(多行模式)等。
- 在下方文本区域输入或粘贴测试文本。
- 匹配部分会实时高亮显示,捕获组单独展示。
- 尝试不同的模式,快速测试和调试你的正则表达式。
Frequently Asked Questions
常见问题
- What is a regular expression? — A regular expression (regex) is a sequence of characters that defines a search pattern. It is used for string matching, validation, and text manipulation in programming.
- What do the flags mean? —
g = global (find all matches, not just the first). i = case-insensitive. m = multiline (^ and $ match per line). s = dotall (. matches newlines).
- What are capturing groups? — Parentheses
() in a regex create capturing groups. Each group captures the text matched by the sub-pattern inside it, which is displayed separately in the results.
- Does this support lookaheads and lookbehinds? — Yes. JavaScript regex supports positive lookahead
(?=...), negative lookahead (?!...), and lookbehind (?<=...) / (?<!...) in modern browsers.
- 什么是正则表达式? — 正则表达式(regex)是定义搜索模式的字符序列,用于字符串匹配、验证和文本处理,在编程中广泛应用。
- 各标志位是什么意思? —
g = 全局匹配(查找所有匹配而非第一个)。i = 不区分大小写。m = 多行模式(^ 和 $ 匹配每行)。s = 单行模式(. 匹配换行符)。
- 什么是捕获组? — 正则中的括号
() 创建捕获组,每个组捕获子模式匹配的文本,在结果中单独显示。
- 支持前瞻和后顾吗? — 支持。JavaScript 正则支持正向先行
(?=...)、负向先行 (?!...),以及现代浏览器支持的后行断言 (?<=...)。
← Back to all tools← 返回所有工具