gpt4 book ai didi

Xcode : exclude matches from result set? 中的正则表达式

转载 作者:行者123 更新时间:2023-12-05 00:39:52 25 4
gpt4 key购买 nike

寻找在 Xcode 的“项目查找”中使用的正确正则表达式语法,以获取所有出现的“nslog”而不是“//nslog”。可以独立进行每个搜索,但不确定如何“链接”它们。

最佳答案

用正则表达式说“不遵循”的正常方法是使用 (?<!...)构造。所以有可能

(?<!//)nslog

may work. It depends on which regex flavor the tool you’re using follows, which is something I don’t know. But it’s been an hour since you asked, and no one else has offered you any answers, so I figure it can’t hurt anything to try.

In case you cannot do lookbehind negations, a pattern that’s guaranteed to work anywhere is

[^/][^/]nslog

然而,那个 不代表和之前的模式一样!

不是说一定不要跟在两个斜杠后面,而是意味着在此之前必须有两个非斜杠。这些实际上是不同的;考虑 nslog 的情况发生在行首。第一种模式会成功,第二种模式会失败。

最后,如果斜杠用作模式分隔符——意思是,它包围并引用模式——那么你必须执行以下操作之一:
  • 选择备用模式分隔符;例如,#(?<!//)nslog#如果你被允许选择一个八索作为你的模式周围的引用分隔符。
  • 对内部使用的任何斜线进行反击并诱发 LTS(倾斜牙签综合症);例如,(?<!\/\/)nslog .
  • 使用某种形式的数字转义,例如 \057八进制或 \x2F十六进制;例如,(?<!\x2F\x2F)nslog .

  • 希望这可以帮助。

    关于Xcode : exclude matches from result set? 中的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4124111/

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