Regex + Remove all text before match

后端 未结 3 1093
情书的邮戳
情书的邮戳 2020-12-19 06:05

I\'m trying to figure out a way to remove all text in a string before match in Regex. I\'m coding this in C#.

For example, if the string is \"hello, test matching\

3条回答
  •  时光说笑
    2020-12-19 06:24

    *Updated, using matchcollection

    string test = "hello, test matching";
    
    string regexStrTest;
    regexStrTest = @"test\s\w+";       
    MatchCollection m1 = Regex.Matches(test, regexStrTest);
    //gets the second matched value
    string value = m1[1].Value;   
    

提交回复
热议问题