last_index_of


Description:

public int last_index_of (string needle, int start_index = 0)

Find the rightmost occurrence of the given string.

Example: Find the rightmost occurrence of a string:

public static int main (string[] args) {
string str = "/this/is/my/file.en.txt";
int i = str.last_index_of (".");

// Output: ``txt``
print ("%s\n", str.substring (i + 1));
return 0;
}

valac --pkg glib-2.0 string.last_index_of.vala

Parameters:

needle

a string to look for

start_index

the starting position for the search in bytes.

Returns:

the byte index of the last occurrence of needle, or -1 if does not occur.