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

后端 未结 4 1163
一向
一向 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:30

    It seems like regular expressions might be useful here. Otherwise, if you know there will only be one number in the textbox, you could select all the chars that are digits and initialize a new string from the array:

    var digitArray = richtextbox1.Text.Where(Char.IsDigit).ToArray();
    string userNum = new String(digitArray);
    Messagebox.Show("The User's Number is " + userNum);
    

提交回复
热议问题