扫码关注官方订阅号
如: NSString = @"http://blog.csdn.net/watsy/article/details/8994865", 新的字符串对象只包含"csdn"?
闭关修行中......
你是想取域名还是啥啊 NSURL *url = [NSURL URLWithString:@"http://blog.csdn.net/watsy/article/details/8994865"]; //blog.csdn.net NSString *host = url.host; //http://blog.csdn.net NSString *hostUrl = [NSString stringWithFormat:@"%@://%@", url.scheme, url.host];
正则表达式。 .?(\w).\w*/ 核心用着一段就可以了,根据你的需求再详细改改就行。
我有一个分割http(s)的 你可以修改一下
(https?):\/\/([^\/]+)(.*) $2就是hostname
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
你是想取域名还是啥啊
NSURL *url = [NSURL URLWithString:@"http://blog.csdn.net/watsy/article/details/8994865"];
//blog.csdn.net
NSString *host = url.host;
//http://blog.csdn.net
NSString *hostUrl = [NSString stringWithFormat:@"%@://%@", url.scheme, url.host];
正则表达式。
.?(\w).\w*/
核心用着一段就可以了,根据你的需求再详细改改就行。
我有一个分割http(s)的 你可以修改一下
(https?):\/\/([^\/]+)(.*) $2就是hostname