If you want an attribute from the anchors, then it's easier to loop through the "a" tags instead of the paragraph nodes. You can use jQuery's "prev()" method to access the preceding "p" and check that its text matches your regex. http://jsfiddle.net/V86t6/13/
function myFunction(){
var mtch = new RegExp(/Regular Edition of 325/);
$('a').each(function () {
if($(this).prev().find("strong").text().match(mtch)) {
document.getElementById("demo").innerHTML=$(this).attr("href")
}
});
}
Note that this code will break if the html changes. Consider wrapping each label/link in a div and iterating over the containers rather than traversing using prev/next/closest, etc.
Since a pure JS version was called for (http://jsfiddle.net/V86t6/15/):
function myFunction(){
var mtch = /Regular Edition of 325/;
Array.prototype.forEach.call(
document.querySelectorAll('p strong'),
function(strong) {
if(strong.innerHTML.match(mtch))
document.getElementById("demo").innerHTML = strong.parentNode.nextElementSibling.href;
}
);
}