是否有公式可从Google表格中的框中提取特定字符?

时间:2019-06-18 09:26:02

标签: regex google-sheets concatenation google-sheets-formula array-formulas

我有6列和4行,例如:

-- Here is what I used, and it works:
create table temp_table like my_table;
-- t_id is my unique column
insert into temp_table (id) select id from my_table GROUP by t_id;
delete from my_table where id not in (select id from temp_table);
drop table temp_table;

现在我希望我的最终数据如下:

A B C D E F,  A B C D,  A B C, A B C D E 

我使用了串联公式,但得到的结果如下:

A>B>C>D>E>F,  A>B>C>D,  A>B>C,  A>B>C>D>E 

在此列中没有可用数据时,我不需要A>B>C>D>E>F, A>B>C>D>, A>B>C>>, A>B>C>D>E> 字符 我尝试过

>>

2 个答案:

答案 0 :(得分:0)

有几种解决方法,例如使用REGEXREPLACESUBSTITUTE

=SUBSTITUTE(A12, ">>", ">")

=REGEXREPLACE(A12, ">>", ">")

0

IF语句,例如:

=ARRAYFORMULA(IF(A1:F1<>"", A1:F1&">", ))

0

=JOIN( , ARRAYFORMULA(IF(A1:F1<>"", A1:F1&">", )))

0


或简单的TEXTJOIN

=TEXTJOIN(">", 1, A1:F1)

0

答案 1 :(得分:0)

df1 <- structure(list(Sno = 1:4, number = c("122, apple, 22, banana", 
"145, 20, 45", "212, grapes, 33", "250, sugar, 43")), class = 
"data.frame", row.names = c(NA, -4L))

df2 <- structure(list(Sno = 1:6, number = c(122L, 186L, 212L, 250L, 
111L, 45L)), class = "data.frame", row.names = c(NA, -6L))

enter image description here