Count Character Occurrence

For a single column, I want a new column with values that are a count of the space characters in the corresponding row. If Column A has “William Howard Taft”, the new column B will have “2” - that is two space characters found. For “Four score and seven years”, column B will have “4”.

How can I achieve this in EDT?

You can do it with a bit of Javascript:

var a = $(1);
var j = 0;
for (var i = 0; i < a.length; i++) 
{
   if ( a[i] == ' ' )
   {
      j++;
   }
}
return j;

sh.transform (1.7 KB)

If there are any leading or trailing spaces, you might need to clean these up first with a Whitespace transform or check trim whitespace on input.