iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
earnrepuNey
V2EX  ›  iDev

有没有 iOS 最强大的 URL 正则表达式?

  •  
  •   earnrepuNey · Jun 19, 2015 · 5415 views
    This topic created in 4024 days ago, the information mentioned may be changed or developed.
    网上能找到的都是针对特定的 URL 格式。有没有能匹配最广的?像微信能识别 t.tt, google.gm 这样的,有没有一个开源的 URL 正则表达式?
    9 replies    2015-07-03 15:28:33 +08:00
    janxin
        1
    janxin  
       Jun 19, 2015
    NSString *urlRegEx =
    @"(http|https)://((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+";
    这个应该就够了把?
    lululau
        2
    lululau  
       Jun 19, 2015
    ruby -ruri -e 'puts URI.regexp'
    zioc
        4
    zioc  
       Jun 19, 2015
    sdk自带的不行吗?不过看不到正则
    earnrepuNey
        5
    earnrepuNey  
    OP
       Jun 24, 2015
    @janxin t.tt 你试试
    earnrepuNey
        6
    earnrepuNey  
    OP
       Jun 24, 2015
    @lk09364 看过,不满足需求
    janxin
        7
    janxin  
       Jun 24, 2015
    @earnrepuNey 没有问题啊,你的意思是不是想匹配不包含http://和https://的url?
    janxin
        8
    janxin  
       Jun 24, 2015
    @earnrepuNey 稍微修改一下就可以了: [(http|https)://]?((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+
    earnrepuNey
        9
    earnrepuNey  
    OP
       Jul 3, 2015
    @janxin 谢谢你的耐心回复。我很好奇微信能够识别 t.tt google.gm 这样的网址。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3731 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 89ms · UTC 04:21 · PVG 12:21 · LAX 21:21 · JFK 00:21
    ♥ Do have faith in what you're doing.