开发者

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]);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜