using System.Text.RegularExpressions;
public partial class MainWindow : Window
{
public void SearchString()
{
Match match = Regex.Match("要被搜尋的文章", "指定要尋找的字串", RegexOptions.IgnoreCase);
// Here we check the Match instance.
if (match.Success)
{
//將文字反白
tb_article.Select(match.Index, match.Length);
}
//滑鼠選取的字串給a變數
sting a = tb_article.SelectedText;
}
}
//在.xaml檔裡設定textbox屬性,可以完成複製和貼上多行的功能 <textbox acceptsreturn="True" x:name="tb_article"></textbox>tb_article為TextBox
沒有留言:
張貼留言