字符
定位符
转义
分组、引用
(ABC) - capturing group
(?:ABC) - non-capturing group
\1 - numeric reference
Lookaround
(?=ABC) - positive lookahead
(?!ABC) - negative lookahead
(?<=ABC) - positive lookbehind
(?<!ABC) - negative lookbehind
限定符
+ - 1 or more
* - 0 or more
? - optional
{1,3}
? - lazy
替换
$& - match
$1 - capture group
Flags
i - case insensitive
g - global search
m - multiline
参考资料
Tip
匹配中文
1
[\u4e00-\u9fa5]
包含指定单词且排除google
1
(?!.*google).*(detail|feed|track).*