Apple开发_提取出字符串中长度为24的UUID子字符串
复制@interface NSString (UUIDExtraction)
- (NSArray<NSString *> *)extract_UUID_Strings;
@end
@implementation NSString (UUIDExtraction)
// 提取出字符串中长度为24的UUID子字符串
- (NSArray<NSString *> *)extract_UUID_Strings {
// 定义一个正则表达式来匹配UUID(这里假设没有连字符)
NSString *uuid_pattern = @"[0-9A-F]{24}";
NSError *error = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:uuid_pattern
options:NSRegularExpressionCaseInsensitive error:&error];
if (error) {
NSLog(@"Error creating regular expression: %@", error.localizedDescription);
return nil;
}
// 执行匹配并收集结果
NSArray *matches = [regex matchesInString:self options:0 range:NSMakeRange(0, self.length)];
NSMutableArray *uuids = [NSMutableArray array];
for (NSTextCheckingResult *match in matches) {
NSRange match_range = [match range];
NSString *uuid = [self substringWithRange:match_range];
[uuids addObject:uuid];
}
return uuids;
}
@end
分类:
Apple开发
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Deepseek官网太卡,教你白嫖阿里云的Deepseek-R1满血版
· 2分钟学会 DeepSeek API,竟然比官方更好用!
· .NET 使用 DeepSeek R1 开发智能 AI 客户端
· DeepSeek本地性能调优
· autohue.js:让你的图片和背景融为一体,绝了!
2018-08-02 UITableView
2018-08-02 NSString
2018-08-02 UIButton
2018-08-02 NSDictionary、NSMutableDictionary
2018-08-02 Apple开发_注释
2018-08-02 UIActionSheet
2018-08-02 UIActivityIndicatorView