$regex($1-,/\b[A-Z]+\b/g)
Note that right now the boundaries for the uppercase alpha words are \b, which will match the position between a non alphanumeric char and an alphanumeric char.
I do this so that in the sentence: WHAT? It would say there's 1 word in upper case, even though technically the string "WHAT?" is not an alpha string, since it contains a question mark. Also in a string like: HEY, you! it will also say there's 1 word in upper case, even though the string "HEY," isn't an alpha string.
Consequence of this is that on the word "SEMI-advanced" it will say there is 1 word in upper case, even though the entire word contains an "-" sign, so isn't technically an alpha char.
If you do only want it to match nothing but alpha chars that can only be surrounded by either a space or the start/end of the string, you could specify:
$regex($1-,/(?<= |^)[A-Z]+(?= |$)/g)
Note that you didn't need a regex for this, a simple loop like the following would have worked just fine.
var %a
while ($0) {
if ($1 isupper) && ($1 isalpha) inc %a
tokenize 32 $2-
}
echo -a %a