returns the number of characters between the first character of a value and an occurrence of a specified string.
# Metadata
Platforms: desktop, server, mobile OS: mac, windows, linux, ios, android Introduced: 1.0 Security:
# Syntax
offset(charsToFind, stringToSearch [, charsToSkip])
# Params
- charsToFind : - stringToSearch : - charsToSkip : A non-negative integer. If you don't specify how many charsToSkip, the offset function does not skip any items and starts at the beginning of the stringToSearch.
# Examples
offset("c","abcde") -- returns 3
offset("b","abacadabra",2) -- returns 6
offset("bark","embarking") -- returns 3
# Description
The value returned by the offset function is the number of the character where charsToFind appears in stringToSearch. If the charsToFind is not in stringToSearch, the offset function returns zero.
If the charsToFind contains more than one character, and the entire charsToFind appears in the stringToSearch, the offset function returns the character number where the charsToFind starts.
If you specify how many charsToSkip, the offset function skips the specified number of characters in the stringToSearch. The value return is relative to this starting point instead of the beginning of the stringToSearch.
>*Note:* The offset is affected by the caseSensitive property. >By default, this property is set to false, meaning uppercase letters >and their lowercase equivalents are treated as the same. For example, offset("A","abcABC") >returns 1 by default, however after setting the caseSensitive to >true, it returns 4 instead.
# Tags
# See
- **property:** caseSensitive - **operator:** begins with - **keyword:** character, characters, integer, string, point - **control structure:** function - **function:** wordOffset, itemOffset, length, lineOffset, value - **command:** find, sort container - **glossary:** return, non-negative, property