get meta element property with Javascript Regex
How would i construct a Javascript regex to get the content attribute from the following meta element?
<meta c开发者_开发技巧ontent="59.949444" property="og:latitude">
This is what my code looks like so far:
var url = 'test.html';
$.get(url, function(data){
var pattern = /property="og:latitude"\scontent=".+?"/;
var matches = data.match(pattern);
console.info(matches[0]);
});
Swap the order of the items:
/content=\"(.+)\"\s+property=\"og:latitude\"/
Try this:
//...
var pattern = /property="og:latitude"\scontent="(.+?)"/;
var matches = data.match(pattern);
console.info(matches[1]);
精彩评论