需要删除大括号之间的字符串 [英] Need to remove string which in between the braces
本文介绍了需要删除大括号之间的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要删除一些额外的字符串,它们介于()之间可能吗?如果这样,请告诉我需要做的事情。
I need to Remove some extra string that which coming in between the "(" ")" is this possible?. If so kindly tell me the way that need to do.
例如首席程序员分析师(#5641)。我需要删除(和)之间的字符串#5641。
For example "Lead Programmer Analyst(#5641)". I need to remove the string #5641 that which is between ( and ).
谢谢你,
S。
Thank you, S.
推荐答案
将您的字符串传递给下面的方法,它将返回正确的字符串
pass Your string to the below method , it will return the proper string
- (NSString *)stringCleaner:(NSString *)yourString {
NSScanner *theScanner;
NSString *text = nil;
theScanner = [NSScanner scannerWithString:yourString];
while ([theScanner isAtEnd] == NO) {
[theScanner scanUpToString:@"(" intoString:NULL] ;
[theScanner scanUpToString:@")" intoString:&text] ;
yourString = [yourString stringByReplacingOccurrencesOfString:
[NSString stringWithFormat:@"%@)", text]
withString:@""];
}
return yourString;
}
这篇关于需要删除大括号之间的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文