in reply to Index of the last occurence of a character inside a string

There's a function to do just that: rindex


Unless I state otherwise, all my code runs with strict and warnings