regular expression

Number of words of a String in a WebL program

I found the solution after browsing through different official samples.
First I get the text content of the node with the method Text(). Then I split the String using the method Str_Search() and a regular expression. The size of the resulting array is the number of the words plus one.

And here is my solution:
PrintLn ("Number of words: ", Size(Str_Search(Text(articleFont[0]), "[0-9a-zA-Z’]+")) - 1);

Subscribe to regular expression