标签:nbsp str pre range size Fix start ast raft
字符串中查找指定字符方法
//开头
-(BOOL) hasPrefix:(NSString *)aString;
//结尾
-(BOOL) hasSuffix:(NSString *)aString;
//中间
-(NSRange) rangeOfString:(NSString *)aString;
例如:
NSString *filename = @"draft-chapter.pages";
if([filename
hasPrefix:@"draft"])
{
}
if([filename
hasSuffix:@".mov"])
{
}
NSRange range;
range = [filename
rangeOfString:@"chapter"];
返回 range.start = 6 range.length
= 7
如果没有找到 range.start =
NSNotFound
标签:nbsp str pre range size Fix start ast raft
原文地址:https://www.cnblogs.com/lnsylt/p/10128939.html