这是JS文件中的数据:
[{\"value\":16633,\"name\":\"fdgdfgdf@joindiaspora.com\"},{\"value\":16910,\"name\":\"jamesw@wk3.org\"},{\"value\":16911,\"name\":\"sdasfasf@joindiaspora.com\"}]" ),
我希望将它输出为二维数组,如:
值名称,
16633 fdgdfgdf@joindiaspora.com,
16910 jamesw@wk3.org,
16911 sdasfasf@joindiaspora.com
到目前为止,这是我的代码:
$.ajax
({
async: false,
type: 'GET',
url: 'https://wk3.org/conversations/new',
success: function(data)
{
var matches;
var Ragex = /\\"value\\":\\"(.*)\\",\\"name\\":\\"(.*)\\"},/g //need to sort out the REGEX so it goes through each name and ID seeing if it equals ID
while ((matches = Ragex.exec(data)) !== null)
{
console.log(matches);
}
}
});
输出:
["\"value\":\"16633\",\"name\":\"fdgdfgdf@joindiaspora.com\"},…"},{\"value\":\"16910\",\"name\":\"jamesw@wk3.org\"},", "16633\",\"name\":\"fdgdfgdf@joindiaspora.com\"},{\"value\":\…"name\":\"sdasfasf@joindiaspora.com\"},{\"value\":\"16910", "jamesw@wk3.org", index: 92, input: "<script>↵ //<![CDATA[↵ $(document).ready(funct…it" value="Send" />↵</div>↵</form>↵</div>↵</div>↵"]
答案 0 :(得分:1)
\":\"?\"
,对吧?
我对侨民并不熟悉。
在python中,模式(\":\").(\")
应该成为
答案 1 :(得分:1)
$.ajax
({
async: false,
type: 'GET',
url: 'https://wk3.org/conversations/new',
success: function(data)
{
var matches;
var name;
var regex = /{\\"value\\":\\"([^"]*)\\",\\"name\\":\\"([^"]*)\\"}/g //need to sort out the REGEX so it goes through each name and ID seeing if it equals ID
while ((matches = regex.exec(data)) !== null)
{
console.log(matches);
var name = matches[2];
if(name == ID)
{
result = matches[1];
}
else
{
console.log("FAIL");
//this sends a message to me only
//need to add error trapping saying recipient cannot be found!
}
}
}
});