我只会用函数解,超长火车- =LET(x,A2,_a,MID(x,SEQUENCE(LEN(x)),1),_b,N(_a="e"),_c,SCAN(,_b,LAMBDA(x,y,IF(y=1,x+y,y))),_d,IF(_c=0,_a,_a&"-"&_c),_e,VSTACK(DROP(REDUCE(0,SEQUENCE(ROWS(_d)-1),LAMBDA(x,y,LET(_e1,INDEX(_d,y),_f,INDEX(_d,y+1),IF(AND(LEN(_e1)=3,LEN(_f)=3),VSTACK(x),VSTACK(x,_e1))))),1),TAKE(_d,-1)),_g,VSTACK(DROP(REDUCE("a",DROP(_e,-1),LAMBDA(x,y,IF(AND(ISNUMBER(FIND("e",y)),ISNUMBER(--TAKE(x,-1))),VSTACK(x,2&"-"&TEXTAFTER(y,"-")),IF(AND(ISNUMBER(--y)*1=0,ISNUMBER(FIND("-",TAKE(x,-1)))),VSTACK(DROP(x,-1),"e"&"-"&TEXTAFTER(TAKE(x,-1),"-"),y),VSTACK(x,y))))),1),TAKE(_e,-1)),_h,DROP(REDUCE(0,_g,LAMBDA(x,y,VSTACK(x,IF(LEN(y)>1,LET(_a,TEXTSPLIT(y,"-"),_b,T(ROW(INDIRECT("1:"&@TAKE(_a,,-1)))),_b&@_a),y)))),1),CONCAT(_h))
复制代码
|