Error getting tags :
error 404Error getting tags :
error 404 wordOffset | revDocs | RunRev
Welcome Guest (Log in)
Product Edition
Version
wordOffset
Basics
Expander triangle
Type
Function
Syntax
wordOffset(wordToFind,stringToSearch[,wordsToSkip])
Introduced
1.0
Environment
Desktop, Web and Server
Platform Support
MacOS,Mac OS X,Windows,Linux
Security
None required
Summary
Returns the number of words between the beginning of a value and an occurrence of a specified string.
Examples

wordOffset("hello","Well, hello there") -- returns 2
wordOffset("ball","baseball game") -- returns 1
wordOffset("red","A red ball on a red table",2) -- returns 4

Additional Comments
Expander triangle

Use the wordOffset function to find which word a string occurs in.

Parameters:

The wordToFind is a single word or an expression that evaluates to a word.

The stringToSearch is a string or an expression that evaluates to a string.

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

Value:

The wordOffset function returns a non-negative integer.

Comments:

The value returned by the wordOffset function is the number of the word where wordToFind appears in stringToSearch. If the wordToFind is not in stringToSearch, the wordOffset function returns zero. If the wordToFind is more than one word, the wordOffset function always 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 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) returns 1, even though it is finding the same occurrence, because the first three words are skipped.

User Comments
Expander triangle