寻找在 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/