正则表达式处理文档
```
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
// 正则 格式
NSRegularExpression * egn = [ NSRegularExpression regularExpressionWithPattern:@".+(?=(http:|https:))" options:NSRegularExpressionCaseInsensitive error:nil ] ;
// 文件位置
NSMutableString * baseStr = [ NSMutableString stringWithContentsOfFile:@"/Users/yghl010/Documents/测试/测试/live_source_2022-02-28.txt" encoding:NSUTF8StringEncoding error:nil ];
// 生成正则表达筛选对象
NSArray * arr_result= [egn matchesInString:baseStr options:0 range: (NSMakeRange(0 , baseStr.length))]; __block NSInteger tempindex = 0 ;
// 处理文字
[arr_result enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(NSTextCheckingResult* _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSLog(@"%@", [baseStr substringWithRange: (NSMakeRange(obj.range.location-tempindex , obj.range.length))]) ;
[baseStr replaceOccurrencesOfString:[baseStr substringWithRange: (NSMakeRange(obj.range.location , obj.range.length))] withString:@"" options:NSForcedOrderingSearch range:(NSMakeRange(obj.range.location , obj.range.length))];
//
tempindex = tempindex +obj.range.length ; } ];
// 保存文件
{
[[baseStr dataUsingEncoding: NSUTF8StringEncoding] writeToFile:@"/Users/yghl010/Documents/测试/测试/live_source_n.txt" atomically:YES ];
}
} return 0;
}
```