Google-sheets – How to combine ‘COUNTIF’ with ‘OR’

google sheets

I have a column with the following cell values:

ce
Km
st
Ge
eS
k
lm
LS
lt

I would like to count any cell that contains the letter "s", "t", "m", or "g" but I do not want to double count a cell that has a combination of those letters in it. For example, a cell that has "ts" I would like to count just once, instead of counting both the "s" and the "t".

Is it possible to do this with a formula?

I've tried this formula:

SUM(COUNTIF(G4:G12,{"*s*","*t*","*g*","*m*"}))

which returns 3 (I think it only counts anything with "s").

and this formula:

 "sumproduct(len($G$4:$G$29)
-len
(substitute
(SUBSTITUTE
(SUBSTITUTE
(SUBSTITUTE
(upper($G$4:$G$29)
,""T"",""""),""S"",""""),""G"",""""),""M"","""")))"

which returns 8 because it counts the "st" cell as 2.

Best Answer

A bit shorter:

=SUMPRODUCT(REGEXMATCH(A1:A9,"(?i)[stgm]"))