1.用正则表达式取出需要的字符串( @\".\\$([A-Za-z0-9]{13})\\$.||.\\#([A-Za-z0-9]{13})\\#.||.\\([A-Za-z0-9]{13})\\.||.\\%([A-Za-z0-9]{13})\\%.||.\\€([A-Za-z0-9]{13})\\€.\"
)
有些机型发现闪退用 异常捕捉 try…catch…finally使用
for (NSString *regex in self.commandRegex)
{
if (![CMBCBLStringUtil strNilOrEmpty:regex])
{
NSRegular *regexExp = [NSRegular regular WithPattern:regex
options:NSRegular CaseInsensitive
error:nil];
NSArray *matches = [regexExp matchesInString:aString
options:0
range:NSMakeRange(0, aString.length)];
NSTextCheckingResult *result = [matches AtIndex_cmbc:0];
if (result)
{
NSRange range = [result rangeAtIndex:1];
// 生产环境部分设备发生闪退
@try {
self.commandString = [aString substringWithRange:range];
} @catch (NSException *exception) {
self.commandString = @\"\";
} @finally {
}
break;
}
}
}
对异常的解释
@try {
// 可能会出现崩溃的代码
} @catch (NSException *exception) {
// 捕获到的异常exception
// 抛出异常
@throw exception
} @finally {
// 结果处理
}
继续阅读与本文标签相同的文章
上一篇 :
Nginx之详解 rewrite URI重写
-
两问快递涨价
2026-05-19栏目: 教程
-
一图了解顺丰全球供应链网络布局
2026-05-19栏目: 教程
-
这款 IDE 插件再次升级,让「小程序云」的开发部署提速 8 倍
2026-05-19栏目: 教程
-
专注于技术能力提升的央企,注定不平凡,我有看点!
2026-05-19栏目: 教程
-
男友力爆棚的Mac电脑办公软件WPS Office
2026-05-19栏目: 教程
