Core Function LastIndexOf

From Sputnik Wiki
Jump to: navigation, search
LastIndexOf( <expression>, <needle>, <pos>, <case>, <count> )

Contents

Description

Reports the index of the last occurrence of the specified string in the current string.

Parameters specify the starting search position in the current string and the type of search to use for the specified string.

expression

The string to use.

needle

The string to find.

pos

Optional; Position to start the search from within the expression.

Default: expression length - 1

case

Optional; Case sensitive option

false = Case sensitive search

true = Case insensitive search

Default: false

count

Optional; The amount of characters to check before quitting the search

Default: pos + 1

Return Value

Success: Returns last position of the found string in the string.

Failure: Returns -1.

Remarks

None.

Example

Case sensitive

println(   LastIndexOf("FoX The quick brown FoX", "FoX")   );

Case insensitive

my $str = "FoX The quick brown FoX";
println(   LastIndexOf($str, "fox", strlen($str) - 1, true)   );

Another example

$pathName = "C:\\WINDOWS\\TEMP\\WSREWE.DAT";
$position = LastIndexOf($pathName, "\\") + 1;
$fileName = substr($pathName, $position);
print("$fileName\n"); //Prints: WSREWE.DAT
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox