CharOffsetBefore

Typeoperator
DictionaryLCB
LibraryLiveCode Builder
Syntax
the ( first | last ) offset of <Needle> before <Before> in <Target>
Associationscom.livecode.char
Summary

Finds the first or last occurrence of Needle before a specified index in Target.

Parameters
NameTypeDescription
Needle

An expression which evaluates to a string.

Target

An expression which evaluates to a string.

Before

An expression which evaluates to a valid integer index of Target.

Example
variable tVar as Number
variable tLastDot as Number
variable tAddress as String
variable tTLD as String
put "http://www.livecode.com/index.html" into tAddress
put the last offset of "." in tAddress into tLastDot
put the offset of "." before tLastDot in tAddress into tVar
put char tVar + 1 to tVar + 3 of tAddress into tTLD -- tTLD contains "com"
Values
NameTypeDescription
return

Returns the offset of Needle before Before in Target.

Description

The first (respectively last) offset of Needle in Target is number of chars between the first char of Target, and the first (respectively last) occurrence of Needle in the substring of Target ending at char Before - 1. If neither first or last is specified, then the last offset is found. If Needle does not occur in the given substring of Target, then the output is 0.

Tagsstrings