如何解析从Android的一个字符串的URL? [英] How to parse a url from a String in android?

查看:763
本文介绍了如何解析从Android的一个字符串的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Android中的String解析URL。这个例子字符串是

I want to parse the url from a String in android. The example String is

"This is a new message. The content of the message is in 'http://www.example.com/asd/abc' "

我想解析URL http://www.example.com/asd/abc 从字符串不使用的子方法。

I want to parse the url http://www.example.com/asd/abc from the String without using the subString method.

推荐答案

更新:

您可以使用普通的EX pression与<一个href="http://developer.android.com/reference/android/util/Patterns.html"><$c$c>Patterns.WEB_URL常规的前pression找到所有的URL文本。

You can use regular expression with Patterns.WEB_URL regular expression to find all urls in your text.

原文:

您可以使用<一个href="http://developer.android.com/reference/android/net/Uri.html#parse%28java.lang.String%29"><$c$c>Uri.parse(String uriString中) 功能。

You can use Uri.parse(String uriString) function.

这篇关于如何解析从Android的一个字符串的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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