zoukankan      html  css  js  c++  java
  • NSURL 子串截取

    NSURL *url = [NSURL URLWithString:@"http://reg.email.163.com/unireg/call.do?cmd=register.entrance&from=163navi&regPage=163"];
        
        NSLog(@"Scheme: %@", [url scheme]);
        
        NSLog(@"Host: %@", [url host]);
        
        NSLog(@"Port: %@", [url port]);
        
        NSLog(@"Path: %@", [url path]);
        
        NSLog(@"Relative path: %@", [url relativePath]);
        
        NSLog(@"Path components as array: %@", [url pathComponents]);
        
        NSLog(@"Parameter string: %@", [url parameterString]);
        
        NSLog(@"Query: %@", [url query]);
        
        NSLog(@"Fragment: %@", [url fragment]);
        
        NSLog(@"User: %@", [url user]);
        
        NSLog(@"Password: %@", [url password]);

    打印结果:

    2016-04-21 14:15:27.929 NSURLtestDemo[2658:107786] Scheme: http
    2016-04-21 14:15:27.929 NSURLtestDemo[2658:107786] Host: reg.email.163.com
    2016-04-21 14:15:27.929 NSURLtestDemo[2658:107786] Port: (null)
    2016-04-21 14:15:27.929 NSURLtestDemo[2658:107786] Path: /unireg/call.do
    2016-04-21 14:15:27.929 NSURLtestDemo[2658:107786] Relative path: /unireg/call.do
    2016-04-21 14:15:27.930 NSURLtestDemo[2658:107786] Path components as array: (
        "/",
        unireg,
        "call.do"
    )
    2016-04-21 14:15:27.930 NSURLtestDemo[2658:107786] Parameter string: (null)
    2016-04-21 14:15:27.930 NSURLtestDemo[2658:107786] Query: cmd=register.entrance&from=163navi&regPage=163
    2016-04-21 14:15:27.930 NSURLtestDemo[2658:107786] Fragment: (null)
    2016-04-21 14:15:27.930 NSURLtestDemo[2658:107786] User: (null)
    2016-04-21 14:15:27.930 NSURLtestDemo[2658:107786] Password: (null)

    需要对URL部分子串进行比较,需要截取其中一些字段,这种方式比较直观。

  • 相关阅读:
    cvsmooth平滑处理函数
    对图像频率的一些理解
    VIM 如何切换buffer
    Mplab X IDE 安装DMCI
    测试 使用橘子曰
    wlr设置 Blog Ping
    wlr快捷键
    使用Windows Live Writer写文章时不要用360清除垃圾
    如何将Windows live writer草稿转存到其他电脑上
    使用windows live writer写cnblog-1 安装wlr
  • 原文地址:https://www.cnblogs.com/wlsxmhz/p/5416768.html
Copyright © 2011-2022 走看看