You could try to refer to the following code to extract text from RichTextBox and match the string.
The code of xaml:
<StackPanel>
<RichTextBox Name="rtbPaste" Height="50" TextChanged="rtbPaste_TextChanged" ></RichTextBox>
</StackPanel>
The code of xaml.cs:
private void rtbPaste_TextChanged(object sender, TextChangedEventArgs e)
{
TextRange textRange = new TextRange(rtbPaste.Document.ContentStart, rtbPaste.Document.ContentEnd);
string _Text = textRange.Text.Replace(Environment.NewLine, "");
if (_Text.Equals("Hello"))
{
MessageBox.Show("Will you count me in?");
}
}
The picture of result: