Finding a not constant char.set in an NSString
I have an NSString with data for ex.:
{SCENE*169/doprava/doprava_tabulka {} {} {} 1299234095} {SCENE*169/doprava/doprava_video {} {} {} 1299234166}
I would like delete parts "brackests and the number", but the numers are not constatnt.
{} 开发者_运维知识库{} {} 1299234095 {} {} {} 1299234166
How can I delete this?
I'd use NSRegularExpression
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:
@"((?: \\{\\}){3} [0-9]+)" options:0 error:nil];
NSMutableString *str = [NSMutableString stringWithString:
@"{SCENE*169/doprava/doprava_tabulka {} {} {} 1299234095} {SCENE*169/doprava/doprava_video {} {} {} 1299234166}"];
[regex replaceMatchesInString:str options:0 range:NSMakeRange(0, [str length]) withTemplate:@""];
str
value here is {SCENE*169/doprava/doprava_tabulka} {SCENE*169/doprava/doprava_video}
But if you develop for iOS, it's only available since 3.2.
精彩评论