It can be implemented with a formula or a regex
I only know how to use this formula, but it's definitely not right.I don't want to do it in a circular way.
Length(txt)-Length(Substitute(txt, " ", ""))
Thanks!