我有以下几行:

Message:Polarion commit Mon May 18 06:59:37 CEST 2009
Message:Polarion commit Fri May 15 19:39:45 CEST 2009
Message:424-18: use new variable
Message:Polarion commit Fri May 15 19:29:10 CEST 2009
Message:Polarion commit Fri May 15 19:27:23 CEST 2009
Message:000-00: do something else
Message:Polarion commit Fri May 15 17:50:30 CEST 2009
Message:401-103: added application part
Message:Polarion commit Fri May 15 17:48:46 CEST 2009
Message:Polarion commit Fri May 15 17:42:04 CEST 2009

我想得到所有不包含“Polarion”的行

我该怎么办?

ps:我看到了:
Regex to match against something that is not a specific substring
但这对我没有帮助

pps:我正在tortoiseSVN中尝试选择日志消息,并且我认为“负向后看”存在问题

最佳答案

这种表现将完成这项工作。

^(?:.(?<!Polarion))*$

它使用零宽度的负向后断言来断言该字符串不包含“Polarion”。
    ^                  Anchor to start of string
    (?:                Non-capturing group
        .              Match any character
        (?<!Polarion)  Zero-width negative lookbehind assertion - text to the
                       left of the current position must not be "Polarion"
    )
    *                  Zero or more times
    $                  Anchor to end of string

The following version will perform the assertion only after a 'n' - maybe this will be faster, maybe slower.

^(?:[^n]*|n(?<!Polarion))*$

10-05 22:09