简体   繁体   中英

Google sheets: Count Specific Characters in a string of words

I have on Google sheets this data (It is the same principle in 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 0
2 5G 0
3 10G/20G/24g 2

I would like instead in returns me this:

Product dose Count "/"
1
2 5G 1
3 10G/20G/24g 2

How I can modify my formula to return me this?

In 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,""))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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