gpt4 book ai didi

用于匹配不包含单词的行的正则表达式

转载 作者:行者123 更新时间:2023-12-03 22:19:42 24 4
gpt4 key购买 nike

我有以下几行:

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))*$

关于用于匹配不包含单词的行的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/876927/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com