Home > front end >  How to Flip a string in google sheets
How to Flip a string in google sheets

Time:09-27

I have this google sheets input column on the left, I want to flip the string like shown in the output column.

Input   Output
--------------
bats    stab
live    evil
meet    teem
part    trap
stop    pots

CodePudding user response:

Use this formula, just replace A2:A range with yours.

=ArrayFormula(IF(A2:A="","",
              BYROW(A2:A, LAMBDA(range, 
              TEXTJOIN("",FALSE,MID(range,SEQUENCE(LEN(range),1,LEN(range),-1),1))))))

enter image description here

Used formulas help
enter image description here

or:

=IFERROR(BYROW(A1:A, LAMBDA(x, JOIN(, INDEX(REGEXREPLACE(""&x, 
 REPT("(.)", LEN(x)), "$"&LEN(x)-SEQUENCE(1, LEN(x), )))))))

enter image description here

CodePudding user response:

try:

=IFERROR(BYROW(A1:A, LAMBDA(x, JOIN(, 
 INDEX(MID(x, LEN(x)-SEQUENCE(1, LEN(x)) 1, 1))))))

enter image description here

CodePudding user response:

Split the string to it's characters using delimiter, then REDUCE the string using current&accumulator(reversal happens here):

=REDUCE(,SPLIT(REGEXREPLACE(A2,,"           
  • Related