First index before a position

前端 未结 5 1915
天涯浪人
天涯浪人 2021-01-21 18:49

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

5条回答
  •  天涯浪人
    2021-01-21 19:22

    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");

提交回复
热议问题