Find specific text in RichTextBox and set it to a string c#

后端 未结 4 1166
一向
一向 2021-01-28 13:56

I am at a loss as to how to do this. I am printing some information to a richtextbox that will be multiple lines, has words and numbers. I need to search the richtextbox for spe

4条回答
  •  难免孤独
    2021-01-28 14:06

    With regex, you can have:

    string pattern = @"[0-9]+";
    string input = @"Matt's number for today 
    is 33 and OK.";
    RegexOptions options = RegexOptions.Multiline;
    
    Console.WriteLine("Matt's number is: {0}", Regex.Matches(input, pattern, options)[0].Value);
    

提交回复
热议问题