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 に答える