findLast

Find last occurrence of a string within another string

Information

This information is part of the Modelica Standard Library maintained by the Modelica Association.

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.

Syntax

index = findLast(string, searchString, startIndex, caseSensitive)

Inputs (4)

string

Type: String

Description: String that is analyzed

searchString

Type: String

Description: String that is searched for in string

startIndex

Default Value: 0

Type: Integer

Description: Start search at index startIndex. If startIndex = 0, start at length(string)

caseSensitive

Default Value: true

Type: Boolean

Description: = false, if lower and upper case are ignored for the search

Outputs (1)

index

Type: Integer

Description: Index of the beginning of the last occurrence of 'searchString' within 'string', or zero if not present