1. rangeofstring: Intercept the length of the specified string;
2. substringToIndex:7:截取从0 索引到指定索引(7)长度的字符串 (从0到7)
3. substringFromIndex:9:截取从指定索引(9)到末尾长度的字符串 (从9到0)
4. substringWithRange:NSMakeRange(4,2):截取从指定索引(4)到指定(2)长度的字符串 (从4开始后的2个)
5. isEqualToString:@"p://www":比较字符串包含关系,区分大小写
6. stringWithFormat:格式化字符串。
I. Define a string A, intercept a project group of a, copy to B, B must be of type int
NSString *a = @ "1.2.30";
int b= [[a Substringwithrange:nsmakerange (4,2)] intvalue];
NSLog (@ "a:%@ \ n", a);
NSLog (@ "b:%d", b);
output:2011-07-05 11:49:08.170 q[4005:207] a:1.2.30
2011-07-05 11:49:08.172 q[4005:207] b:30
The parsing is as follows: Substringwithrange: A piece of string specifically intercepted
Nsmakerange (4,2) from the beginning of the 4th character intercept, the length of 2 characters, (the string is the beginning of the No. 0 character of the first number OH ~!) )
Two. String intercept to Nth bit (substringtoindex:n) (nth bit not counted)
NSString *a = @ "I like long dress";
NSString *b = [a substringtoindex:4];
NSLog (@ "B:%@", b);
2011-07-11 18:12:40.119 q[6321:207] b:i Li
Three. The string is truncated from the beginning of the nth bit until the last (substringfromindex:n) (contains nth bits)
NSString *a = @ "I like long dress";
NSString *b = [a substringfromindex:4];
NSLog (@ "B:%@", b);
2011-07-11 18:15:08.125 q[6366:207] b:ke long dress
IOS NSString intercept strings (intercepted by index)