zoukankan      html  css  js  c++  java
  • oc--截取字符串(从网址中截取用户名和密码)

    /*截取字符串 从网址中截取用户名和密码*/
     2         NSString *str=@"http://localhost:8090.cn?user=adminator&pwd=1234ABCD";
     3         NSRange range1=[str rangeOfString:@"user="];
     4         NSRange range2=[str rangeOfString:@"&pwd="];
     5         NSUInteger userlocation=range1.location+range1.length;
     6         NSUInteger userlength=range2.location-(range1.location+range1.length);
     7         NSRange userRange={userlocation,userlength};// 自定义一个结构体范围
     8         NSString *str1=[str substringWithRange:userRange];
     9         NSLog(@"user=%@",str1);
    10         NSUInteger strlen=[str length];
    11         NSUInteger pwdlocation=userlength+userlocation+range2.length;
    12         NSUInteger pwdlength=strlen-(userlength+userlocation+range2.length);
    13         NSRange pwdRange={pwdlocation,pwdlength};// 自定义一个结构体范围
    14         NSString *str2=[str substringWithRange:pwdRange];
    15         NSLog(@"pwd=%@",str2);
  • 相关阅读:
    pip本地源搭建
    linux 创建 bootable iso 文件
    yum 源本地化 (two)
    linux 网络配置
    linux 设置root可以远程登陆
    察看linux 发行版
    mysql bin-log 设置
    samba 奇怪问题
    delphi中的临界区
    ligerGrid 取得选中行的数据
  • 原文地址:https://www.cnblogs.com/jiangyicheng/p/5114044.html
Copyright © 2011-2022 走看看