Home > Software design >  How To Extract ALL Similar Characters From A Text Using Google Sheets
How To Extract ALL Similar Characters From A Text Using Google Sheets

Time:09-03

How do I extract all the following strings only?

""scr"":[13,7,6]
""scr"":[7,3,4]
""scr"":[6,4,2]
""scr"":[20,8,12]
""scr"":[12,5,7]
""scr"":[8,3,5]

From a cell containing the text as below;

 " function get_meja(type){ if(type==""h""){ return 
{""ft"":{""scr"":[13,7,6],""un1.5"":[3,2,1],""un2.5"":[3,2,1],""un3.5"":[8,3,5],""bts"":[2,1,1],""cnd"":[9,2,7],""ch"":[4,2,2],""sn"":[6,3,3],""pl"":[9,4,5]},""ht1"":{""scr"":[7,3,4],""un1.5"":[8,4,4],""un2.5"":[8,4,4],""un3.5"":[9,4,5],""bts"":[1,0,1],""cnd"":[4,1,3],""ch"":[5,3,2],""sn"":[6,3,3],""pl"":[9,4,5]},""ht2"":{""scr"":[6,4,2],""un1.5"":[4,2,2],""un2.5"":[8,3,5],""un3.5"":[9,4,5],""bts"":[1,1,0],""cnd"":[5,1,4],""ch"":[6,3,3],""sn"":[3,2,1],""pl"":[9,4,5]}}; 
}else{ return 
{""ft"":{""scr"":[20,8,12],""un1.5"":[0,0,0],""un2.5"":[4,3,1],""un3.5"":[5,3,2],""bts"":[6,1,5],""cnd"":[11,3,8],""ch"":[3,3,0],""sn"":[9,4,5],""pl"":[9,4,5]},""ht1"":{""scr"":[12,5,7],""un1.5"":[5,2,3],""un2.5"":[8,4,4],""un3.5"":[9,4,5],""bts"":[2,1,1],""cnd"":[2,1,1],""ch"":[7,3,4],""sn"":[9,4,5],""pl"":[9,4,5]},""ht2"":{""scr"":[8,3,5],""un1.5"":[4,3,1],""un2.5"":[6,3,3],""un3.5"":[8,4,4],""bts"":[4,1,3],""cnd"":[9,2,7],""ch"":[3,3,0],""sn"":[6,3,3],""pl"":[9,4,5]}}; 
} } "

I tried using this formula:

=TRANSPOSE(SPLIT(REGEXREPLACE(REGEXREPLACE(I6,"scr-un", ","), "^,|,$", ""), ","))

But I am getting undesirable results: enter image description here

CodePudding user response:

try:

=ARRAYFORMULA(REGEXREPLACE(QUERY(FLATTEN(SPLIT(
 REGEXREPLACE(A1, "(""""scr)", "♦$1"), "♦")), "offset 1", 0), ","". ", ))

enter image description here

  • Related