寻找在 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#
如果你被允许选择一个八索作为你的模式周围的引用分隔符。 (?<!\/\/)nslog
. \057
八进制或 \x2F
十六进制;例如,(?<!\x2F\x2F)nslog
. 希望这可以帮助。
关于Xcode : exclude matches from result set? 中的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4124111/