【求助】:如何使用正则式对文本进行查找替换?
例句:“中华人民共和国成立于1949年10月1日,I、U、R、#”
查找其中的“1949、10、1、I、U、R、#”
然后替换成“中华人民共和国成立于一九四九年十月一日,电流、电压、电阻、号”
如何用一句正则式进行查找替换呢? 正则
[解决办法]
System.IO.StreamReader reader1 = new System.IO.StreamReader("e:\\1.txt",Encoding.Default);
string str = @"中华人民共和国成立于1949年10月1日,I、U、R、#";
string strmatch = @"(?is)[\d]+
[解决办法]
[a-z]
[解决办法]
#";
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(strmatch);
System.Text.RegularExpressions.MatchCollection mc = reg.Matches(str);
foreach (System.Text.RegularExpressions.Match mm in mc)
{
MessageBox.Show(mm.Value);
}