W_COUNT()
Syntax
Count as N = W_COUNT( Input_String as C [, Word_Delimiter as C ] )
Argument | Description |
Input_String | A character string |
Word_Delimiter | Optional. Default = space (" "). The character that separates words. If the optional Word_Delimiter parameter is not specified, a word is any sequence of one or more characters separated either by a space or the start or end of the string. |
Description
W_COUNT() returns an integer Count equal to the number of words in the specified Input_String.
You may often need to extract the last name from a field that contains both a first name and last name, or the zip code from a field that contains the city, state, and zip. This can be a difficult problem because, in the case of names, for example, some records can contain middle initials. In the case of addresses, some city names can be one word and others may be two words. Using W_COUNT() , you can count the number of words in a field. This makes it easy to extract the last word in a field.
If Word_Delimiter is specified, then Alpha Five, then Alpha Five counts the strings that are delimited by the Word_Delimiter character.
Supported By
Alpha Five Version 5 and Above
Example
w_count("Phineas T. Whopee") -> 3 w_count(CITYSTZIP) -> 3, if CITYSTZIP contains "Yorktown Heights, NY10598" |
To extract the last name from a field that contains full names, use the following expression:
word(FULLNAME, w_count(FULLNAME)) |
An alternative to using W_COUNT() is to use the WORD() function with a negative parameter. The following expression also returns the last word in a field:
word(FULLNAME,-1) w_count("John Smith" + "," + "Alpha Software" + "," + "BurlingtonMA01803", ",") -> 3 |
See Also