我试图删除iOS中我的字符串中的所有括号.看到这个stackoverflow帖子:如何删除空格,括号和"来自nsarray
答案:
NSCharacterSet *charsToTrim = [NSCharacterSet characterSetWithCharactersInString:@"()"];
s = [s stringByTrimmingCharactersInSet:charsToTrim];
Run Code Online (Sandbox Code Playgroud)
但这只是删除一个括号(来自mystring.如何删除所有这些?
我的代码看起来像这样:
NSCharacterSet *charsToTrim = [NSCharacterSet characterSetWithCharactersInString:@"( )"];
attributedLabel.text = [attributedLabel.text stringByTrimmingCharactersInSet:charsToTrim];
NSLog(@"%@",attributedLabel.text);
Run Code Online (Sandbox Code Playgroud)
需要一些指导......
Vin*_*yne 15
请尝试使用
[[attributedLabel.text stringByReplacingOccurrencesOfString:@"(" withString:@""] stringByReplacingOccurrencesOfString:@")" withString:@""];
.
| 归档时间: |
|
| 查看次数: |
4811 次 |
| 最近记录: |