如何在SwiftLint中匹配多行正则表达式



我正在尝试标记使用一个或多个函数或属性创建的协议。首先,我在正则表达式测试程序中创建了一些正则表达式,它与协议中的多个函数相匹配。然而,当我使用该规则构建应用程序时,它与具有多个功能的协议不匹配。

custom_rules:
protocol_more_than_one_function:
name: "Protocol with more than one function"
regex: 'protocol.*{n.*func.*n.*func'
message: "If you would like to create a protocol with more than one function, then cretae separate protocols with one function each, then combine them with a typealias. For example, typealias BothProtocols = firstProtocol & secondProtocol"
severity: warning

我正在测试的代码是:

protocol GroupedProtocol {
func stuff()
func stuff2()
}

我认为这是因为swift lint regex不接受多行regex参数。什么regex可以在构建时实现这一点?

我一个字符接一个字符。正则表达式在{上中断
我不得不这样逃离:{

smh

最新更新