Lookaheads
jeffrey@envato.com
jeffrey@jeffrey-way.com
jeffrey@envato.edu
jeffrey@jeffrey-way.au
jeffrey@jeffrey-way.tv 正则匹配表达式: `@.+(?=\.[a-z]{2,4})` <!--more-->
解释:
@
匹配@.
匹配任意字符\.[a-z]{2,4}
\.
匹配一个.
,[a-z]
匹配所有小写字母{2,4}
匹配小写字母2-4次。- (?=)匹配但不包含上面的匹配结果
negative lookahead matching
joe@envato.com
jeffrey@jeffrey-way.com
jeffrey@envato.edu
jeffrey@jeffrey-way.au
jeffrey@jeffrey-way.tv 正则匹配表达式:` (?<!jeffrey)@.+ `
解释:
- (?<!jeffrey)匹配前面不包含jeffrey的行,上面示例结果为
@envato.com
Positive lookbehind matching
- 只需把前面(?<!)
Positive lookahead.
box-sizeing
box-shadow 正则匹配表达式: ` box(?=-shadow) `
解释:
- 只匹配后面有 -shadow 的字符,但不包含
Negative lookbehind matching
box-sizeing
box-shadow 正则匹配表达式: box(?!-shadow)
解释:
- 只匹配后面不包含 -shadow 的字符