此代码搜索富文本框并将数组的第一个字段替换为第二个字段。除了两个字段外,一切都很好。
iEmo = new string[,] {
{@":\)", Smile},
{@":\(", Sad},
{@"8\)", Cool},
{@":\|", Neutral},
{@";\)", Wink},
{@">:\(", Evil}, // Won't work for this one
{@">:D", Twisted}, // Or this one
{@":\?", Question,}
};
这是将数组转换为我想要的部分:
public void SetSmiley(RichTextBox RichBox) {
for (int i = 0; i < (iEmo.Length / 3); i++) {
try {
RichBox.Rtf = Regex.Replace(RichBox.Rtf, iEmo[i, 0], iEmo[i, 1], RegexOptions.IgnoreCase);
}
catch (Exception e){}
}
}