0

这是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" />↵&lt;/div>↵&lt;/form>↵&lt;/div>↵&lt;/div>↵"]
4

2 回答 2

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!
            }
        }
    }

});
于 2013-04-27T21:21:15.617 回答
1

你想捕捉?在\":\"?\",对吧?

我对侨民不熟悉。

在python中,模式(\":\").(\")应该使它

于 2013-04-27T19:30:21.180 回答