形式が変わらない場合は、正規表現を使用する必要はありません。
NSScanner
、特にメソッドscanUpToString:intoString:
とを使用してみてくださいscanString:intoString:
編集:
このコードは、必要なものである必要があります。
NSString *example = @"#parsed Value1:1a 2013-02-20 10:00:00 UTC Value2=2a Value3=3a Value4=4aKm Value5=A";
NSString *temp, *value1, *date, *value2, *value3, *value4, *value5;
NSScanner *scanner = [NSScanner scannerWithString:example];
// By default, NSScanner will skip whitespace - we don't want it to skip anything here
[scanner setCharactersToBeSkipped:[NSCharacterSet characterSetWithCharactersInString:@""]];
[scanner scanString:@"#parsed Value1:" intoString:&temp];
[scanner scanUpToString:@" " intoString:&value1];
[scanner scanString:@" " intoString:&temp];
[scanner scanUpToString:@" Value2=" intoString:&date];
[scanner scanString:@" Value2=" intoString:&temp];
[scanner scanUpToString:@" Value3=" intoString:&value2];
[scanner scanString:@" Value3=" intoString:&temp];
[scanner scanUpToString:@" Value4=" intoString:&value3];
[scanner scanString:@" Value4=" intoString:&temp];
[scanner scanUpToString:@" Value5=" intoString:&value4];
[scanner scanString:@" Value5=" intoString:&temp];
value5 = [example substringFromIndex:[scanner scanLocation]];