#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
@autoreleasepool {
/* nsstring *[email protected] "Apple banana pear";
Nsarray *array=[str componentsseparatedbystring:@ ""];
NSLog (@ "%@", array); */
/*//substringtoindex from the beginning of the string to the location you specified, but not the location you specified
NSString *[email protected] "ABCDEFG";
NSString *newstr1=[str1 Substringtoindex:4];
NSLog (@ "%@", NEWSTR1);
Substringfromindex all characters starting at the specified position (and including the specified position)
NSString *newstr2=[str1 Substringfromindex:4];
NSLog (@ "%@", NEWSTR2); */
/*//intercept string by range
NSString *[email protected] "ABCDEFG";
Nsrange rang;
rang.location=2;
rang.length=3;
NSString *NEWSTR3=[STR3 Substringwithrange:rang];
NSLog (@ "%@", NEWSTR3); */
NSString *[email protected] "http://localhost:8099/test/user=admin&pwd=123";
Nsrange rang= [String rangeofstring:@ "pwd="];
NSLog (@ "Location=%ld,length=%ld", rang.location,rang.length);
NSLog (@ "pwd=%@", [string substringfromindex:rang.location+rang.length]);
}
return 0;
}
Find its exact location and length based on the specific information in the string