replace_capturestr.m
NSString *str = @"hogehogefugao";
NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:@"(hoge).+(fugao)" options:0 error:nil];
NSString *new_str = [regexp
stringByReplacingMatchesInString:str options:0 range:NSMakeRange(0, str.length) withTemplate:@"$1山$2"];
//new_strは hoge山fugaoになります。
キャプチャと、リプレイスはこんな感じにできる。すぐ忘れるからメモ代わりに。