functionfindLast

Find last occurrence of a string within another string

Extends from Modelica.Icons.Function (Icon for functions).

Information

Syntax

index = Strings.findLast(string, searchString);
index = Strings.findLast(string, searchString,
                         startIndex=length(string), caseSensitive=true,

Description

Finds first occurrence of "searchString" within "string" when searching from the last character of "string" backwards, and return the corresponding index. Start search at index "startIndex" (default = 0; if startIndex = 0, search starts at length(string)). If the optional argument "caseSensitive" is false, lower and upper case are ignored for the search. If "searchString" is not found, a value of "0" is returned.

It is intended for ASCII, the case-insensitive count is not guaranteed to work for UTF-8.

Inputs

TypeNameDefaultDescription
StringstringString that is analyzed
StringsearchStringString that is searched for in string
IntegerstartIndex0Start search at index startIndex. If startIndex = 0, start at length(string)
BooleancaseSensitivetrue= false, if lower and upper case are ignored for the search

Outputs

TypeNameDefaultDescription
IntegerindexIndex of the beginning of the last occurrence of 'searchString' within 'string', or zero if not present