什么是正则表达式?
正则表达式(Regular Expression,简称 Regex)是一种用于描述字符串模式的强大工具。它使用特殊的语法规则来定义搜索模式,广泛应用于文本搜索、替换、验证和数据提取等场景。
本工具支持以下功能:
- 实时匹配:输入正则表达式和测试字符串后,自动高亮显示所有匹配结果
- 分组捕获:显示每个匹配的捕获组内容,方便调试复杂正则
- 标志位设置:支持全局(g)、多行(m)、忽略大小写(i)、点匹配换行(s)、Unicode(u)等标志
- 错误提示:实时检测正则语法错误,帮助快速定位问题
常用正则示例:邮箱 /^[\w.-]+@[\w.-]+\.\w+$/、手机号 /^1[3-9]\d9$/、URL /^https?:\/\/.+/
What is a Regular Expression?
A Regular Expression (Regex) is a powerful tool for describing string patterns. It uses special syntax rules to define search patterns and is widely used for text search, replacement, validation, and data extraction.
This tool supports:
- Real-time Matching — Automatically highlights all matches as you type the regex and test string
- Capture Groups — Shows captured group content for each match, helpful for debugging complex regex
- Flag Settings — Supports global (g), multiline (m), case-insensitive (i), dot-all (s), and Unicode (u) flags
- Error Detection — Real-time regex syntax error detection to help quickly identify issues
Common regex examples: Email /^[\w.-]+@[\w.-]+\.\w+$/, Phone /^1[3-9]\d9$/, URL /^https?:\/\/.+/