我想匹配所有包含大写字符的行,但忽略字符串A_
为了增加复杂性,我想忽略不同字符串之后的所有内容,例如公开评论
以下是应该匹配和不应该匹配的示例
Matches:
- fooBar
- 富酒吧富
- A_fooBar
- fooBar /* 注释 */
不匹配(C_ 不应触发匹配)
- A_foobar
- foo A_bar
- foobar
- 富巴 富巴
- foobar /* 评论 */
谢谢 :)
这应该(也?)做到这一点:
(?!A_)[A-Z](?!((?!/\*).)*\*/)
简短的解释:
(?!A_)[A-Z] # if no 'A_' can be seen, match any uppercase letter
(?! # start negative look ahead
((?!/\*).) # if no '/*' can be seen, match any character (except line breaks)
* # match zero or more of the previous match
\*/ # match '*/'
) # end negative look ahead
所以,用简单的英语来说:
匹配除“A_”之外的任何大写字母,并且如果在没有首先遇到“/*”的情况下可以看到“*/”,则也不是大写字母。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)