所以我得遵循這種模式很長的txt文件:使用grep在BBEdit中第一後更換模式的每一個實例
},
"303" :
{
"id" : "4k4hk2l",
"color" : "red",
"moustache" : "no"
},
"303" :
{
"id" : "4k52k2l",
"color" : "red",
"moustache" : "yes"
},
"303" :
{
"id" : "fask2l",
"color" : "green",
"moustache" : "yes"
},
"304" :
{
"id" : "4k4hf4f4",
"color" : "red",
"moustache" : "yes"
},
"304" :
{
"id" : "tthj2l",
"color" : "red",
"moustache" : "yes"
},
"304" :
{
"id" : "hjsk2l",
"color" : "green",
"moustache" : "no"
},
"305" :
{
"id" : "h6shgfbs",
"color" : "red",
"moustache" : "no"
},
"305" :
{
"id" : "fdh33hk7",
"color" : "cyan",
"moustache" : "yes"
},
,我試圖格式化它是一個結構如下正確的JSON對象....
"303" :
{ "list" : [
{
"id" : "4k4hk2l",
"color" : "red",
"moustache" : "no"
},
{
"id" : "4k52k2l",
"color" : "red",
"moustache" : "yes"
},
{
"id" : "fask2l",
"color" : "green",
"moustache" : "yes"
}
]
}
"304" :
{ "list" : [
etc...
意思是我找^「\ d \ d \ d」的所有模式:而離開第一唯一的,但刪除所有後續者(例如,留下「303」的第一個實例:,但完全刪除其餘的,然後保留「304」的第一個實例:,但是完全刪除其餘的人等等)。
我一直在嘗試將應用程序的BBEdit,這對搜索一個grep的選項之內做到這一點/替換。我的模式匹配功能太弱,無法完成此任務。有任何想法嗎?或者更好的方法來完成這項任務?