FindLastOf, FindFirstOf function]

Requires: GfaWinx.lg32

Purpose

Searches a string for the last (FindLastOf) or first (FindFirstOf) character that matches the specified characters.

Syntax

i = FindLastOf (sChrs, s [, npos])

i = FindFirstOf (sChrs, s [, npos])

Description

FindLastOf searches the string s for the last of any of the characters in sChr. The return value is the position of the last character that matches. When npos (base 1) is specified, the search only includes characters at or before position npos, ignoring any possible occurrences after npos.

FindFirstOf searches the string s for the first any of the characters in sChr. The return value is the position of the first character that matches. When npos (base 1) is specified, the search only includes characters at or after position npos, ignoring any possible occurrences before npos.

Example

$Library "gfawinx"

Debug.Show

Trace FindLastOf("\.:", "C:\WINDOWS\SYSTEM.INI")        ' = 18

Trace FindLastOf("\.:", "C:\WINDOWS\SYSTEM.INI", 17)    ' = 11

Trace FindFirstOf("\.:", "C:\WINDOWS\SYSTEM.INI")       ' = 2

Trace FindFirstOf("\.:", "C:\WINDOWS\SYSTEM.INI", 4 )   ' = 11

Remarks

FindLastOf is also known under the name LastDelimiter.

See Also

EndsWith, InStr, Left$, Mid$, Mode, Right$, RInStr(), StartsWith

{Created by Sjouke Hamstra; Last updated: 18/12/2022 by James Gaite}