提取部分 URL [英] Extract part of URL

查看:24
本文介绍了提取部分 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网址,需要提取其中的一部分.

I have an URL and need to extract a part of it.

网址是这样的:
http:///website.com/get.php?url=http://www.website2.com/index.html?articleID=123456

The url is like this:
http://website.com/get.php?url=http://www.website2.com/index.html?articleID=123456

我需要提取这部分:
http://www.website2.com/index.html?articleID=123456

And I need to extract this part:
http://www.website2.com/index.html?articleID=123456

我将如何在 Objective-C 中做到这一点?

How would I do this in Objective-C?

推荐答案

首先,创建一个 NSURL.然后,使用query方法获取查询字符串部分:

First of all, create a NSURL. Then, use the querymethod to get the query string part:

NSURL    * url = [ NSURL URLWithString: @"... your url ..." ];
NSString * q   = [ url query ];

然后你可以使用 NSString 方法来隔离需要的部分.

Then you can use the NSString methods to isolate the needed part.

这篇关于提取部分 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆