I have a string and index in that string, and want to get the first position of a substring before that index.
e.g., in string:
\"this is a test string tha
You can simply take the substring from 0 to index and on this substring ask for the last index of it
YourString.substring(0,index).LastIndexOf("string");