Product SiteDocumentation Site

7.4.77. WORDPOS (Word Position)


>>-WORDPOS(phrase,string--+--------+--)------------------------><
                          +-,start-+

Returns the word number of the first word of phrase found in string or returns 0 if phrase contains no words or if phrase is not found. Several whitespace characters between words in either phrase or string are treated as a single blank for the comparison, but otherwise the words must match exactly.
By default, the search starts at the first word in string. You can override this by specifying start (which must be positive), the word at which to start the search.
Here are some examples:

Example 7.105. Builtin function WORDPOS

WORDPOS("the","now is the time")              ->  3
WORDPOS("The","now is the time")              ->  0
WORDPOS("is the","now is the time")           ->  2
WORDPOS("is   the","now is the time")         ->  2
WORDPOS("is   time ","now is   the time")     ->  0
WORDPOS("be","To be or not to be")            ->  2
WORDPOS("be","To be or not to be",3)          ->  6