网上能找到的都是针对特定的 URL 格式。有没有能匹配最广的?像微信能识别 t.tt, google.gm 这样的,有没有一个开源的 URL 正则表达式?
|
janxinJun 19, 2015
1
NSString *urlRegEx =
@"(http|https)://((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+"; 这个应该就够了把? |
|
lululauJun 19, 2015
2
ruby -ruri -e 'puts URI.regexp'
|
|
lk09364Jun 19, 2015
3
Keywords: regex url stackoverflow
http://stackoverflow.com/questions/161738/what-is-the-best-regular-expression-to-check-if-a-string-is-a-valid-url |
|
ziocJun 19, 2015
4
sdk自带的不行吗?不过看不到正则
|
|
5
|
|
6
@lk09364 看过,不满足需求
|
|
janxinJun 24, 2015
7
@earnrepuNey 没有问题啊,你的意思是不是想匹配不包含http://和https://的url?
|
|
janxinJun 24, 2015
8
@earnrepuNey 稍微修改一下就可以了: [(http|https)://]?((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+
|
|
9
|