STD.Str.CountWords( source, separator, [allow_blank] )
STD.Uni.CountWords( source, separator, [allow_blank] )
source | A string containing the words to count. |
separator | A string containing the word delimiter to use. |
allow_blank | Optional, A BOOLEAN value indicating if empty/blank string items are included in the results. Defaults to FALSE |
Return: | CountWords returns an integer value. |
The CountWords function returns the number of words in the source string based on the specified separator.
Words are separated by one or more separator strings. No spaces are stripped from either string before matching.
Example:
IMPORT Std; str1 := 'a word a day keeps the doctor away'; str2 := 'a|word|a|day|keeps|the|doctor|away'; OUTPUT(LENGTH(TRIM(Str1,LEFT,RIGHT)) - LENGTH(TRIM(Str1,ALL)) + 1); //finds eight words by removing spaces STD.STr.CountWords(str1,' '); //finds eight words based on space delimiter STD.STr.CountWords(str2,'|'); //finds eight words based on bar delimiter