开发者

match dates with jquery

开发者 https://www.devze.com 2023-02-21 04:13 出处:网络
I want to match these tags: <div>03-24-2010</div> <div>04-23-2011</div> With jquery:

I want to match these tags:

<div>03-24-2010</div>
<div>04-23-2011</div>

With jquery:

("div:contains([0-9]{2}-[0-9]{2}-[0-9]{4})")
开发者_运维百科

What do I need to do to the regular expression here to make it work (using phpquery - php implementation of jquery)?


Try this:

var divs = $("div").filter(function(){
return /[0-9]{2}-[0-9]{2}-[0-9]{4}/.test($(this).text());
});


jQuery doesn't support regex selectors out of the box. You need to use a plugin in or something like http://james.padolsey.com/javascript/regex-selector-for-jquery/ (a filter)

0

精彩评论

暂无评论...
验证码 换一张
取 消