1

我需要比较 word 文档中的两个字符串,我计算出字母和数字值,但它无法比较包含一些特殊字符的字符串,例如 (Máceres-Cartínez) 这里 a 和 i 出现在特殊字符中,所以它不是比较。

我的代码如下。StreamReader sr = new StreamReader(this.textBox1.Text); 字符串 strValue = sr.ReadToEnd(); 字符串[] strSpliter =新字符串[1];strSpliter[0] = "参考"; string[] strSplitValue = strValue.Split(strSpliter, StringSplitOptions.None); String[] strParaValue = strSplitValue[1].Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); FileStream fst = new FileStream(@"E:\TrueText.txt",FileMode.Append); StreamWriter swt = new StreamWriter(fst); FileStream fsf = new FileStream(@"E:\FalseText.txt", FileMode.Append); StreamWriter swf = new StreamWriter(fsf);

            swt.WriteLine("Startred on :" + DateTime.Now.ToString("yyyy/MM/dd/hh/mm/ss") + "\n");
            swf.WriteLine("Startred on :" + DateTime.Now.ToString("yyyy/MM/dd/hh/mm/ss") + "\n");

            foreach (string strPara in strParaValue)
            {
                string[] strAuthorsPart = strPara.Split('.');
                string[] strAuthorslist = strAuthorsPart[0].Split(',');
                string[] strAuthor = strAuthorslist[0].Split(' ');
                if (strSplitValue[0].Contains(strAuthor[0].Trim()))
                {
                    swt.WriteLine(strAuthor[0] + "\t");
                }
                else
                {

                    swf.WriteLine(strAuthor[0] + "\t");
                }

有没有人指导我如何解决这个问题?

谢谢迪戈

4

2 回答 2

0

我看不到你的代码。也许这可以帮助你:

bool result = Regex.IsMatch("\\bthe\\b", text);

(using System.Text.RegularExpressons.)
StreamReader sr = new StreamReader(this.textBox1.Text);
            string strValue = sr.ReadToEnd();
            string[] strSpliter =new string[1];
            strSpliter[0] = "References";
            string[] strSplitValue = strValue.Split(strSpliter, StringSplitOptions.None);
            String[] strParaValue = strSplitValue[1].Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            FileStream fst = new FileStream(@"E:\TrueText.txt",FileMode.Append);
            StreamWriter swt = new StreamWriter(fst);
            FileStream fsf = new FileStream(@"E:\FalseText.txt", FileMode.Append);
            StreamWriter swf = new StreamWriter(fsf);

            swt.WriteLine("Startred on :" + DateTime.Now.ToString("yyyy/MM/dd/hh/mm/ss") + "\n");
            swf.WriteLine("Startred on :" + DateTime.Now.ToString("yyyy/MM/dd/hh/mm/ss") + "\n");

            foreach (string strPara in strParaValue)
            {
                string[] strAuthorsPart = strPara.Split('.');
                string[] strAuthorslist = strAuthorsPart[0].Split(',');
                string[] strAuthor = strAuthorslist[0].Split(' ');
                if (strSplitValue[0].Contains(strAuthor[0].Trim()))
                {
                    swt.WriteLine(strAuthor[0] + "\t");
                }
                else
                {

                    swf.WriteLine(strAuthor[0] + "\t");
                }

这是我的代码

于 2012-04-04T11:11:51.053 回答
0

自定义案例映射。

于 2012-04-04T11:21:59.073 回答