jQuery Selector与正则表达式 [英] jQuery Selector with regex
本文介绍了jQuery Selector与正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望扫描页面并查找任何包含 price
一词的类或ID的html元素。我的想法是在这里使用正则表达式,但我无法正确启动它。
I am looking to scan a page and look for any html elements that have a class or id that contains the word price
. My thought was to use regex here but I cannot get it to fire correctly.
我在OS X上使用Safari和Chrome
I am using Safari and Chrome on OS X
var price = $("div:regex(\bprice\b)").text();
目的是在电子商务网站上获取产品的价格(如果不是已在Open Graph中说明已经处理过。
The purpose is to get the price of a product on an e-commerce site if it isn't already stated in Open Graph which is already handled.
推荐答案
\ b
与\ x08
相同。
逃脱 \
:
var price = $("div:regex(\\bprice\\b)").text();
这篇关于jQuery Selector与正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文