First index before a position

前端 未结 5 1919
天涯浪人
天涯浪人 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

    So you want the last index before a given index...

    var myString = "this is a test string that contains other string for testing";
    myString = String.SubString(0, 53);
    var lastIndexOf = myString.LastIndexOf("string");
    

提交回复
热议问题