我如何构造一个Javascript正则表达式来从下面的meta元素中获取内容属性?
<meta content="59.949444" property="og:latitude">到目前为止,我的代码是这样的:
var url = 'test.html';
$.get(url, function(data){
var pattern = /property="og:latitude"\scontent=".+?"/;
var matches = data.match(pattern);
console.info(matches[0]);
});发布于 2011-06-17 07:08:20
交换项目的顺序:
/content=\"(.+)\"\s+property=\"og:latitude\"/发布于 2011-06-17 07:25:34
试试这个:
//...
var pattern = /property="og:latitude"\scontent="(.+?)"/;
var matches = data.match(pattern);
console.info(matches[1]);https://stackoverflow.com/questions/6379593
复制相似问题