Name: wordOffset

Type: function

Syntax: wordOffset(<wordToFind>, <stringToSearch> [, <wordsToSkip>])

Summary:
<return|Returns> the number of <words> between the beginning of a
<value> and an occurrence of a specified <string>.

Introduced: 1.0

OS: mac, windows, linux, ios, android

Platforms: desktop, server, mobile

Example:
wordOffset("hello","Well, hello there") -- returns 2

Example:
wordOffset("ball","baseball game") -- returns 1

Example:
wordOffset("red","A red ball on a red table",2) -- returns 4

Parameters:
wordToFind:
A single word or an expression that evaluates to a word.

stringToSearch (string):


wordsToSkip:
A non-negative integer. If you don't specify how many wordsToSkip, the
wordOffset function does not skip any words.

Returns:
The <wordOffset> <function> <return|returns> a <non-negative> <integer>.

Description:
Use the <wordOffset> <function> to find which <word> a <string> occurs
in. 

The value returned by the <wordOffset> <function> is the number of the
<word> where <wordToFind> first appears in <stringToSearch>. If the
<wordToFind> is not in <stringToSearch>, the <wordOffset> <function>
<return|returns> zero. If the <wordToFind> contains more than one <word>, the
<wordOffset> <function> always <return|returns> zero, even if the
<wordToFind> appears in the <stringToSearch>.

If you specify how many <wordsToSkip>, the <wordOffset> <function> skips
the specified number of <words> in the <stringToSearch>. The value
<return|returned> is relative to this starting point instead of the
beginning of the <stringToSearch>.

For example, if the <stringToSearch> is "This is a test" and the
<wordToFind> is "test", wordOffset(wordToFind,stringToSearch) returns 4.
However, wordOffset(wordToFind, stringToSearch,3) <return|returns> 1,
even though it is finding the same occurrence, because the first three
<words> are skipped.

References: function (control structure), offset (function),
lineOffset (function), itemOffset (function), value (function),
return (glossary), non-negative (glossary), integer (keyword),
words (keyword), word (keyword), string (keyword), is among (operator),
caseSensitive (property), wholeMatches (property)

Tags: text processing

