oc--intercept string (user name and password are intercepted from URL)

Source: Internet
Author: User

/*intercept a string to intercept a user name and password from the URL*/ 2NSString *str=@"Http://localhost:8090.cn?user=adminator&pwd=1234ABCD"; 3Nsrange range1=[str rangeofstring:@"user="]; 4Nsrange range2=[str rangeofstring:@"&pwd="]; 5Nsuinteger userlocation=range1.location+range1.length;6Nsuinteger userlength=range2.location-(range1.location+range1.length); 7Nsrange Userrange={userlocation,userlength};//Customizing a structure body range 8NSString *str1=[str substringwithrange:userrange];9NSLog (@"user=%@", str1);TenNsuinteger strlen=[str length]; OneNsuinteger pwdlocation=userlength+userlocation+range2.length; ANsuinteger pwdlength=strlen-(userlength+userlocation+range2.length); -Nsrange Pwdrange={pwdlocation,pwdlength};//Customizing a structure body range -NSString *str2=[str substringwithrange:pwdrange]; theNSLog (@"pwd=%@", str2);

oc--intercept string (user name and password are intercepted from URL)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.