Core Function LastIndexOfAny

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

Contents

Description

Reports the index of the last occurrence of any characters or array of strings in a specified 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 characters to find (as a string) or an array of strings 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 character or string in the string.

Failure: Returns -1.

Remarks

None.

Example

Case sensitive

// Find characters
println(   IndexNotOfAny("The quick brown FoX", "ehT")   );
// Find from a string
println(   LastIndexOfAny("The quick brown FoX", array("FoX"))   );
// Find from an array of strings
println(   LastIndexOfAny("The quick brown catFoX", array("Fox", "cat"))   );

Case insensitive

// Find characters
println(   IndexNotOfAny("The quick brown FoX", "eht", 0, true)   );
// Find from a string
my $str = "The quick brown FoX";
println(   LastIndexOfAny($str, array("foX"), strlen($str) - 1, true)   );
// Find from an array of strings
my $str = "The quick brown catFoX";
println(   LastIndexOfAny("The quick brown catFoX", array("Fox", "cat"), strlen($str) -1, true)   );
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox