0

我拥有的字符串示例:

{"prices":"","sTld":"com","sSld":"test1","available":false,"type":"","options":""}
{"prices":"","sTld":"co.uk","sSld":"test2","available":false,"type":"","options":""}
{"prices":"","sTld":"in","sSld":"test3","available":false,"type":"","options":""}
{"prices":"","sTld":"lt","sSld":"test4","available":false,"type":"","options":""}

我想提取这些值:

com, co.uk, in, lt
test1, test2, test3, test4

换句话说,我想从 sTld 中提取从“:”到“”的每个值,以及从“:”到“”的 sSld 中的值。

我想我需要为此使用正则表达式,但我不知道如何。有什么建议么?

4

2 回答 2

1

试试这个,

var obj=[{"prices":"","sTld":"com","sSld":"test1","available":false,"type":"","options":""},
{"prices":"","sTld":"co.uk","sSld":"test2","available":false,"type":"","options":""},
{"prices":"","sTld":"in","sSld":"test3","available":false,"type":"","options":""},
{"prices":"","sTld":"lt","sSld":"test4","available":false,"type":"","options":""}];
$.each(obj, function(index, value) {
    console.log(value.sTld);
    console.log(value.sSld);
});

小提琴

于 2013-07-01T12:13:36.370 回答
0
$.each(json, function(index, value) {
    console.log(value.sTld);
    console.log(value.sSld);
});
于 2013-07-01T12:07:22.533 回答