Get string between two strings in a string

前端 未结 23 2178
别跟我提以往
别跟我提以往 2020-11-22 09:46

I have a string like:

\"super exemple of string key : text I want to keep - end of my string\"

I want to just keep the string which is betw

23条回答
  •  伪装坚强ぢ
    2020-11-22 10:40

    Here is the way how i can do that

       public string Between(string STR , string FirstString, string LastString)
        {       
            string FinalString;     
            int Pos1 = STR.IndexOf(FirstString) + FirstString.Length;
            int Pos2 = STR.IndexOf(LastString);
            FinalString = STR.Substring(Pos1, Pos2 - Pos1);
            return FinalString;
        }
    

提交回复
热议问题