If a substring appears several times in a string, how can I find the position of the last occurrence of the substring in the string?
E.g.
str = 'This is a pen. This is a pen. This is a pen'
The position of the last "pen" is 40, so the answer should be 40.