LastIndexOfEnd

Top  Previous  Next

 

The LastIndexOfEnd Special Function Command allows you to obtain the zero based Index of the end of a set of one or more specified characters within a string.

lamp Important: Special Function commands can only be used on the right hand side of a Variable Assignment command.

Command Syntax

 

LastIndexOfEnd,[SearchFor],[OriginalString],[StringComparison]

 

The comma character after the command is compulsory as are all three parameters and the commas separating them.

 

Parameters:

 

SearchFor: The string to search for within the original string

OriginalString: The string to search

StringComparison: A string representing a member of the StringComparison enumeration:

 

SearchFor and OriginalString parameters are compulsory, the StringComparison parameter is optional. If provided, the value must be one of the following:

 

CurrentCulture

Compare strings using culture-sensitive sort rules and the current culture.

 

CurrentCultureIgnoreCase

Compare strings using culture-sensitive sort rules, the current culture, and ignoring the case of the strings being compared.

 

InvariantCulture

Compare strings using culture-sensitive sort rules and the invariant culture.

 

InvariantCultureIgnoreCase

Compare strings using culture-sensitive sort rules, the invariant culture, and ignoring the case of the strings being compared.

 

Ordinal

Compare strings using ordinal (binary) sort rules.

 

OrdinalIgnoreCase

Compare strings using ordinal (binary) sort rules and ignoring the case of the strings being compared.

 

If no StringComparison parameter is provided, the default StringComparison.Ordinal will be used.

 

If any required parameter is missing or invalid an error will be thrown. All parameters must be surrounded by quotation marks if one or more commas are included. It is good practice to include the quotation marks in any case, so that it reduces the risk of error when writing scripts.If the string contains no instances of the SearchFor value are located in the original string -1 will be returned.

lamp Important: Any string containing or consisting of one or more commas MUST be enclosed in double quotes, otherwise an error will be thrown.

Example:

 

Retrieve the Index of the word 'Version:' and insert the installed version number of Windows Media Player after it:

 

Var:VersionString="The File Version:"

Var:Version=GetFileVersion,"C:\Program Files (x86)\Windows Media Player\wmplayer.exe"

Var:VersionIndex=LastIndexOfEnd,"Version:","%%VersionString%%",true

Var:Sentence=Insert,"%%VersionString%%","%%Version%% ",%%VersionIndex%%

 

See Also: Special Functions Insert Substring GetFileVersion