简体   繁体   English

谷歌表格:计算一串单词中的特定字符

[英]Google sheets: Count Specific Characters in a string of words

I have on Google sheets this data (It is the same principle in excel).我在谷歌表上有这些数据(这在 excel 中是相同的原理)。

I want to count the numbers of dose in each strings.我想计算每个字符串中的剂量数。

I use this formula and it return me this:我使用这个公式,它返回给我这个:

=LEN(L3)-LEN(SUBSTITUTE(L3,"/",""))
Product产品 dose剂量 Count "/"数数 ”/”
1 1 0 0
2 2 5G 5G 0 0
3 3 10G/20G/24g 10G/20G/24g 2 2

I would like instead in returns me this:我想改为返回我这个:

Product产品 dose剂量 Count "/"数数 ”/”
1 1
2 2 5G 5G 1 1
3 3 10G/20G/24g 10G/20G/24g 2 2

How I can modify my formula to return me this?我如何修改我的公式来返回这个?

In C2 :C2中:

=ARRAYFORMULA(IF(LEN(B2:B),LEN(B2:B)-LEN(SUBSTITUTE(B2:B,"/",""))+1,""))

Or:或者:

=ARRAYFORMULA(IF(LEN(B2:B),LEN(REGEXREPLACE(B2:B,"[^/]",""))+1,""))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM