我拥有的字符串示例:
{"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中的值。
我想我需要使用正则表达式,但我不知道如何。有什么建议?
答案 0 :(得分: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);
});
答案 1 :(得分:0)
$.each(json, function(index, value) {
console.log(value.sTld);
console.log(value.sSld);
});