1, the Interception of strings
//1. Intercepting StringsNSString*string=@"123456d890"; NSString*STR1 = [stringSubstringtoindex:5];//intercept the string before the drop Mark 5NSLog (@"The Intercept value is:%@", STR1); NSString*STR2 = [stringSubstringfromindex:3];//intercept the string after the drop Mark 3NSLog (@"The Intercept value is:%@", str2);
2. Match string
Finds (matches) a string (Ad) from a string (SD is SFSFSADFSDF)
//2. Matching stringsNSString *string=@"SD is SFSFSADFSDF"; Nsrange Range= [stringRangeofstring:@ "Ad"];//match the resulting subscriptNSLog (@"rang:%@", Nsstringfromrange (range));string= [stringSubstringwithrange:range];//intercept a string within a rangeNSLog (@"The Intercept value is:%@",string);
3. String segmentation
To split a string based on a character (a) in a string
// 3. Separating strings NSString *String =@ "sdfsfsfsadfsdf"; *array = [string componentsseparatedbystring:@ "A"// An array of 2 elements separated from character a NSLog (@ "array:%@"// result is ADFSFSFS and DFSDF
String processing for iOS: intercepting strings, matching strings, separating strings