【发布时间】:2013-11-14 07:58:53
【问题描述】:
我正在尝试使用 C# 和正则表达式在 RichTextBox 中进行语音识别,这样当用户单击“查找语音”时,所有语音标记和里面的语音都以蓝色突出显示。但是,我不太清楚如何将查找内部语音与正则表达式结合起来,因为我目前所能做的就是突出显示语音标记。
public void FindSpeech()
{
Regex SpeechMatch = new Regex("\"");
TXT.SelectAll();
TXT.SelectionColor = System.Drawing.Color.Black;
TXT.Select(TXT.Text.Length, 1);
int Pos = TXT.SelectionStart;
foreach (Match Match in SpeechMatch.Matches(TXT.Text))
{
TXT.Select(Match.Index, Match.Length);
TXT.SelectionColor = System.Drawing.Color.Blue;
TXT.SelectionStart = Pos;
TXT.SelectionColor = System.Drawing.Color.Black;
}
}
【问题讨论】:
-
你能告诉我们输入的文本吗?你想精确搜索/匹配什么?
-
一个示例字符串将非常有用。
标签: c# regex find richtextbox speech