gpt4 book ai didi

regex - Powershell - notMatch

转载 作者:行者123 更新时间:2023-12-04 14:16:54 26 4
gpt4 key购买 nike

我想从文件中选择所有与特定模式不匹配的行;
我知道我必须使用 select-string 的 -notMatch 选项,但我不知道如何使用。
(我正在寻找类似 GREP 的 -v 函数的东西)
任何例子都会有用。
提前致谢。

最佳答案

我想你还是想match而不是 notmatch .要排除函数返回类型或注释,您需要“否定断言”。也许这会满足您的要求?

$f = 'my_function'
select-string test.txt -Pattern "(?<!(void|double|char|int)\s+|//.*)\b$f\b"
(?<!...)如果在源文本中的这一点找到“...”,则部分表示不匹配。

关于regex - Powershell - notMatch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10285290/

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