本帖最后由 air123456789 于 2010-09-15 11:06:17 编辑

解决方案 »

  1.   


    Regex.Replace(input, @"(?n)\\(?<a>cf\d+)(\\[^\\\s]+)*\s*(?<b>((?!\\cf).)+)", "$1 $2");
      

  2.   

    这个?            string a = @"\cf1\lang2052\f0\fs30 cf2哈哈,Word \par\cf2
    \f2\fs40 什么呢?cf2 \par\cf3
    \f2 Hello! \cf4 不知道哦。f2 \par\cf2
    \f3 什么什么什么?";
                Regex reg = new Regex(@"(?<=\\)(cf\d)([\w\\]*) (.*?)((?=\\)|(?=$))");
                foreach (Match m in reg.Matches(a.Replace("\r\n","")))
                {
                    Console.WriteLine(m.Groups[1].ToString() + " " + m.Groups[3].ToString());
                }