有一个JS对象是这样的:
{
list: [
{
firstP0: 1,
firstP1: 3,
firstP2: 5,
firstPxxx: xxx,
secondP0: 2,
secondP1: 4,
secondP2: 6,
secondPxxx: xxx,
}
]
}
没办法知道具体的键名,但知道其规律是/firstP\d+/或者/secondP\d+/,如何把它变成这样的结构:
{
list: [
{
first: {
P0: 1,
P1: 3,
P2: 5,
Pxxx: xxx,
},
second: {
P0: 2,
P1: 4,
P2: 6,
Pxxx: xxx,
}
}
]
}
简写如下
