Syntax

offset(<needle>, <haystack>[, <skipCharacters>])

put offset("Hell", "Say hello!") into probablyFive
put offset("Needle", field "Haystack", gLastFoundPos + length("needle")) into nextSearchResult

Explanation

The offset function finds the string <needle> in the string <haystack> and returns the position of the character so that it can be used to access the first character of the found word with the character chunk expression. It returns 0 if the requested needle string could does not occur in the haystack string.

If you specify skipCharacters, offset will skip that many characters at the start of the haystack string before it starts searching. This allows you to search for the next result after you’ve found something, by doing something like:

put offset("Candy", field "Products") into firstResultPos
put offset("Candy", field "Products", firstResultPos + 1) into secondResultPos

Note that the position returned starts at 1 after the skipped characters. So you will have to add skipCharacters to the result to obtain the character number where the second search result starts.

See Also