too*_*oom 4 xcode warnings escaping
在我的代码中,我广泛使用正则表达式,我的模式看起来像这样
regexp = [[NSRegularExpression alloc] initWithPattern:@".*?\\\+.*?\\\+.*?\\\+.*?\\\+.*?\\\+.*?\\\+" options:0 error:nil];
Run Code Online (Sandbox Code Playgroud)
对于转义序列,我得到编译器警告,例如"Unknown escape sequence +",这非常烦人,因为在我的情况下没有错.我怎么能摆脱这个警告?
你必须使用许多反斜杠字符,使用:
regexp = [[NSRegularExpression alloc] initWithPattern:@".*?\\+.*?\\+.*?\\+.*?\\+.*?\\+.*?\\+" options:0 error:nil];
Run Code Online (Sandbox Code Playgroud)
要获得\字符串,需要进行转义:\\.所以\\\+应用第一个\逃避第二个\和第三个\尝试逃避加号+是非法逃脱.
| 归档时间: |
|
| 查看次数: |
7053 次 |
| 最近记录: |