Get string between two strings in a string

前端 未结 23 2403
别跟我提以往
别跟我提以往 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:48

    As I always say nothing is impossible:

    string value =  "super exemple of string key : text I want to keep - end of my string";
    Regex regex = new Regex(@"(key \: (.*?) _ )");
    Match match = regex.Match(value);
    if (match.Success)
    {
        Messagebox.Show(match.Value);
    }
    

    Remeber that should add reference of System.Text.RegularExpressions

    Hope That I Helped.

提交回复
热议问题