作者chhuang (口白人生)
看板C_Sharp
标题Re: [问题] 碰到符号才取代
时间Sat Sep 22 17:35:24 2007
※ 引述《colorsea (OH Yes! Babe~)》之铭言:
: 噗~才刚po完问题,就爬到文了^^"
: 感谢1782篇,ithinkurdumb大大的贡献....
: 问题已解决,附上原始码,给有需要的人参考~~~^^
: string txt = txtPatn.Text.ToString();
: Int32 int1 = txt.IndexOf("[");
: Int32 int2 = txt.IndexOf("]");
: if(int1 != -1 && int2 != -1)
: {
: txt = txt.Remove(int1 + 1, int2-int1-1);
: txt = txt.Insert(int1 + 1, btn.Text.ToString());
: txtPatn.Text = txt;
: }
private void button4_Click(object sender, EventArgs e)
{
txtPatn.Text = Regex.Replace(txtPatn.Text, @"\[(\w+)\]", "[answer]");
}
--
http://blog.roodo.com/chhuang
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.62.84.89