I have some text in a cell (let's say
A1) in Google Sheets and wish to count how many words have initial capital letters. I've tried a couple of things, but neither works:
=countif(split(A1," "),regexmatch(split(A1," "),"^\W*[A-Z]"))
What should I be doing, please?
A couple of notes:
- I want to do this for multiple cells, i.e. to know how many words in
A1are capitalized, how many in
A2are, etc. I doubt that that will affect the answer, but am mentioning it just in case.
- The regular expression I used above is not a good way to check for capitalization in general, and don't use it. (See e.g. the "brokenness" section of Tom Christiansen's "Go Thou and Do Likewise" post on Stack Overflow. It's about Perl, but much of it generalizes.) It happens to work for my data, because my data uses a specific set of characters that it happens to work for. You have been warned.