Javascript正则表达式从文本中获取href属性数据 [英] Javascript regex to get the href attribute data from a text

查看:696
本文介绍了Javascript正则表达式从文本中获取href属性数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用ajax,并且已经检索了一些数据,我想从href属性中提取具有特定类名的url.我需要一个javascript正则表达式来从那堆数据中提取URL.该数据中的网址应如下所示.

I have been working with ajax and I have retrieved some data, I want to extract a url from an href attribute, with specific class name. I need a javascript regex for it to extract me the url from that bunch of data. The URL from that data should look like this.

https://www.facebook.com/username

https://www.facebook.com/username

图片链接,此图片显示了数据以及其特定的类名和href中的网址,我想通过该特定的类名来提取该网址.类名称为: class ="_ 2s25 _606w"

Image Link, this image shows the data, and its specific class name and the url in the href, I want to extract that url, fro, through that specific class name. The class name is : class="_2s25 _606w"

推荐答案

解决方案:$(data).find('._2s25 ._606w').attr('href');.

参考:-从jQuery AJAX请求中解析返回的HTML

这篇关于Javascript正则表达式从文本中获取href属性数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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