首页 > 移动平台 > 详细

iOS搜索指定字符在字符串中的位置

时间:2016-11-23 19:11:57      阅读:408      评论:0      收藏:0      [点我收藏+]
 1 NSString *tmpStr = @"asd341234aaaaccd";  
 2 
 3   NSRange range;  
 4 
 5   range = [tmpStr rangeOfString:@"ccd"];  
 6 
 7 if (range.location != NSNotFound) {  
 8 
 9       NSLog(@"found at location = %lu, length = %lu",(unsigned long)range.location,(unsigned long)range.length);  
10 
11 NSString *ok = [tmpStr substringFromIndex:range.location];  
12 
13       NSLog(@"%@",ok);  
14 
15   }else{  
16 
17       NSLog(@"Not Found");  
18 
19   }

 

iOS搜索指定字符在字符串中的位置

原文:http://www.cnblogs.com/crazygeek/p/6094615.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!