正则表达式:从定位标记中查找网址 [英] regular expression: Find url from anchor tag
本文介绍了正则表达式:从定位标记中查找网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
example:
<a href="http://www.test.com" title="xyz">this is test</a>
我该如何匹配字符串并使用正则表达式获取url.
谢谢
解决方案
how can i match the string and fetch url using regular expression. thanks 这篇关于正则表达式:从定位标记中查找网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!<a\s+([^>]*)href="(https?:\/\/([^"]*))"\s+([^>]*)title="xyz"(.*?)>(.*?)<\/a>
您可以通过部分匹配$2
获取网址,也可以尝试example:
<a href="http://www.test.com" title="xyz">this is test</a>
解决方案 <a\s+([^>]*)href="(https?:\/\/([^"]*))"\s+([^>]*)title="xyz"(.*?)>(.*?)<\/a>
you can get the url by partial match $2
, you can try it here
查看全文