How To Extract ALL Similar Characters From A Text Using Google Sheets - google-sheets
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:
try:
=ARRAYFORMULA(REGEXREPLACE(QUERY(FLATTEN(SPLIT(
REGEXREPLACE(A1, "(""""scr)", "♦$1"), "♦")), "offset 1", 0), ","".+", ))
Related
QUERY simplification with LAMBDA function
I have this formula so I want to make the same QUERY for each variable and join the results. The given formula works (no error in cell) but it give me only the first query result. I want the result to be QUERYRESULT1 / QUERYRESULT2 / QUERYRESULT3, etc. and i could repeeat the query for each variable, but I'm asking for a way to make it with only one line (to simplify). Is it possible? =MAP( BI3:BI;BL3:BL;BO3:BO;BR3:BR;BU3:BU;BX3:BX;CA3:CA;CD3:CD;CG3:CG;CJ3:CJ;CM3:CM;CP3:CP; LAMBDA(f;g;h;i;j;k;l;m;n;o;p;q; TEXTJOIN(" / "; TRUE; IFNA( ARRAYFORMULA( IFERROR(QUERY('BDD Componentes'!AR:AV;"SELECT AV WHERE AR = '"&{f;g;h;i;j;k;l;m;n;o;p;q}&"'";0)) ) ) ) ) )
here I am with the same suggestion as in your previous question. Try it and let me know: =BYROW({BI3:BI\BL3:BL\BO3:BO\BR3:BR\BU3:BU\BX3:BX\CA3:CA\CD3:CD\CG3:CG\CJ3:CJ\CM3:CM\CP3:C}; LAMBDA(r; TEXTJOIN(" / "; TRUE; IFNA( ARRAYFORMULA( IFERROR(QUERY('BDD Componentes'!AR:AV;"SELECT AV WHERE AR = '"&r&"'";0)) ) ) ) ) )
How to replace spaces between words with another word?
I have a cell G which stores random words like "Hello, How are you" I want to replace all the spaces with %20 to make it "Hello%20,%20How%20%are%20you" How can i replace spaces with %20? Thanks
try like this: =SUBSTITUTE(G1; " "; "%20")
Select the cells you wish to change and run this: Sub SpaceChanger() Dim rng As Range, r As Range Set rng = Intersect(Selection, ActiveSheet.UsedRange) For Each r In rng If r.Value <> "" Then If InStr(r.Value, " ") <> 0 Then r.Value = Replace(r.Value, " ", "%20") End If End If Next r End Sub (using a macro will allow you to change the values "in place")
Google Sheets - Equivalent of a FOR loop
A1 = 8 A2 = 14 I don't know if an equivalent for this exists in Google Sheets but what I am trying to do is that for every multiple of 5 in A1 I want to subtract 5 off of A2 and make it one string in A3. So in this example A3 = 14/9 And if A1 = 12; A3 = 14/9/4 This should even go into the negatives in the case of A1 = 16; A3 = 14/9/4/-1 Ultimately I would like to avoid using the API/Script system if possible. Right now the only way I can think of doing it is a ton of IF() handlers. This is the formula I am currently using, but understandably it's a mess and stops working when the IF()'s run out. =A2& IF(A1>5, "/"&A2-5& IF(A1>10, "/"&A2-10& IF(A1>15, "/"&A2-15& IF(A1>20, "/"&A2-20 , "") , "") , "") , "")
=ARRAYFORMULA(QUERY(IF(ROW(INDIRECT("A1:A""IENT(A1, 5)+1)), MMULT(TRANSPOSE(( ROW(INDIRECT("A2:A""IENT(A1, 5)+2))<= TRANSPOSE( ROW(INDIRECT("A2:A""IENT(A1, 5)+2))))* {A2; TRANSPOSE(SPLIT(REPT(5*-1&"♦", QUOTIENT(A1, 5)), "♦"))}), SIGN({A2; TRANSPOSE(SPLIT(REPT(5*-1&"♦", QUOTIENT(A1, 5)), "♦"))})^2), IFERROR(1/0)), "limit ""IENT(A1, 5)&" offset 1"))
try it like this: =A2-QUOTIENT(A1, 5)*5
=IFERROR(ARRAYFORMULA(TO_TEXT(JOIN("/", IF(ROW(INDIRECT("A1:A""IENT(A1, 5)+1)), MMULT(TRANSPOSE(( ROW(INDIRECT("A2:A""IENT(A1, 5)+2))<= TRANSPOSE( ROW(INDIRECT("A2:A""IENT(A1, 5)+2))))* {A2; TRANSPOSE(SPLIT(REPT(5*-1&"♣", QUOTIENT(A1, 5)), "♣"))}), SIGN({A2; TRANSPOSE(SPLIT(REPT(5*-1&"♣", QUOTIENT(A1, 5)), "♣"))})^2), IFERROR(1/0))))))
Adding blank rows in a set of data in Google Sheets
I have a set of data. What i am looking forwards is to add 2 blank rows after each set of 3 values like this Hope to get help in getting this solved. you can find the sample google sheet here : https://docs.google.com/spreadsheets/d/11nMvUWn3xcTfxlk4v30KruPr03HSheMk1jrxZPpJ_p4/edit?usp=sharing Thanks Shijilal
Solution: IF it's the third row, Add 3 bunnies separated by a space, else keep the values as it is JOIN them all and SPLIT by a bunny and TRANSPOSE Sample: =ARRAYFORMULA(TRANSPOSE(SPLIT(TEXTJOIN("🐇",1,IF(MOD(ROW(A2:A16),3)=1,A2:A16&REPT("🐇 ",3),A2:A16)),"🐇")))
Some time ago, I created this custom function that may help you. I changed it slightly to meet your requirement and added it to the script editor. function rowsBetween(range, s, rowsWithData, text) { var n = [], a = [], i = 0; while (i < s) { a.push(text ) i++; } range.forEach(function(r, i) { n.push(r); if((i + 2) % rowsWithData == 1) { a.forEach(function(x) { n.push(x); }); } }); return n; } This script will allow you to enter in the spreadsheet this (custom) formula (see also cell E2) =rowsBetween(A2:A16, 2, 12,) See if that works for you?
How to check a value in an integer range in Google Spreadsheet?
For example, the integer range is separated by comma, such as "4450-4499, 4700-4805, 9920-9959". How to check if an integer is in this range?
Paste values: Cell A1 = 4450-4499, 4700-4805, 9920-9959 Cell B1 = 4450 or any number And use this formula: =IFERROR(JOIN("",QUERY( {ArrayFormula(REGEXEXTRACT(TRANSPOSE(SPLIT(A1,", ")),"(\d+)")*1), ArrayFormula(REGEXEXTRACT(TRANSPOSE(SPLIT(A1,", ")),"-(\d+)")*1)}, "where Col1 <= "&B1&" and Col2 >= "&B1&"",0))*1,0)>0 Will return true bacause 4450 is in range 4450-4499.
This function takes a number and the range and performs the check, but beware that it has no precautions, so the data provided must fit the format you gave: function inRange(number, range) { range = range.split(", "); range = range.map(function(x) {return x.split("-")}); for (var i in range) { if (number >= range[i][0] && number <= range[i][1]) { return true; } } return false; }