これが私のコードです:
NSRegularExpression * regex;
- (void)viewDidLoad {
NSError *error = NULL;
regex = [NSRegularExpression regularExpressionWithPattern:@"<*>" options:NSRegularExpressionCaseInsensitive error:&error];
}
- (IBAction)findWord {
NSString * fileContents=[NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/report1_index1_page1.html", [[NSBundle mainBundle] resourcePath]]];
NSLog(@"%@",fileContents);
NSString * modifiedString = [regex stringByReplacingMatchesInString:fileContents
options:0
range:NSMakeRange(0, [fileContents length])
withTemplate:@"$1"];
NSLog(@"%@",modifiedString);
}
'modifiedString'が(null)を返します。なぜですか?'<'と'>'の間の文字('<'と'>'を含む)を単にスペースで置き換えたいのです。