iPh*_*one 2 iphone objective-c nsstring
我的字符串是 @"Hello, I am working as an ios developer"
现在我想要删除所有字符 "ios"
最后我想删除最后一个空格字符后的所有字符.
我怎样才能做到这一点?
示例代码:
NSString* str= @"Hello, I am working as an ios developer";
// Search from back to get the last space character
NSRange range= [str rangeOfString: @" " options: NSBackwardsSearch];
// Take the first substring: from 0 to the space character
NSString* finalStr = [str substringToIndex: range.location]; // @"Hello, I am working as an ios"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1881 次 |
| 最近记录: |