精通正则表达式
^ 开头
$ 结尾
[] 字符组 或逻辑
- 连字符 表示范围,只有在字符组内,并且形如 a-z 0-9 A-Z
[^] 排除型字符组 [^1-6] 排除1到6
. 任意字符
| 或
() 范围,或者集合的意思,注意和[]字符组的分别,[abc] = (a|b|c) 多选项
\<\> 单词分界符 类似 ^ $,但是不是用在句中,而是单词。经常期望匹配到某个单词而非该单词存在于某个单词这种情况
{} (hello){1,3} 代表匹配hello 1 - 3 次。 [a-z]{2,5} 代表匹配中括号内至少2到5次。
Comments:
Email questions, comments, and corrections to hi@smartisan.dev.
Submissions may appear publicly on this website, unless requested otherwise in your email.