Is there a good way to start at a given index and move BACKWARDS looking for a given phrase in a string? I only know how to use indexof iterating forwards.
You can use LastIndexOf:
int index = s.LastIndexOf("foo");
It also has an optional start index if you want to start search backwards from somewhere other than the end of the string.
int index = s.LastIndexOf("foo", 20);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With