【发布时间】:2015-12-07 13:26:47
【问题描述】:
如果我有如下字符串:
String str = "Google is awesome search engine. https://www.google.co.in";
现在在上面的字符串中,我需要检查字符串是否包含任何链接。在上面的字符串中,它应该返回 true,因为字符串包含一个链接。
该函数应检查www.google.com 也作为链接。它不应该依赖于http:// 或https://
我也检查了这个链接What's the best way to check if a String contains a URL in Java/Android? 但只有当字符串只包含 url 时它才会返回 true,而我想要的是如果字符串在任何地方包含链接,它应该返回 true。
我也想要那个匹配模式的字符串,这样我就可以在 android 的 textview 中设置它并使其可点击。
我该怎么做,请帮帮我。
【问题讨论】: