开发者

match dates 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜