像这样的一段document.write("ddddddddd");
document.write("ddddddddd");
document.write('ddddddddd');

解决方案 »

  1.   

    html是什么样子?
    <p>ddddddd</p>
    这样?
      

  2.   

    string result = Regex.Replace(html,@"document.write\((['"])((?:\\.|[^\\'"])+)\1\);","<p>$2</p>");result就是结果,不过不知道是不是就是你期望的。
    如果不是,跟帖说明。
      

  3.   

    string result = Regex.Replace(html,@"document.write\((['""])((?:\\.|[^\\'""])+)\1\);","<p>$2</p>");
      

  4.   


    不好意思,应该是这种格式的:document.writeln("<p>dfdfdf<\/p>");
    document.writeln("fdfdfdf");
    document.writeln("<span>dfdfdfdgg<\/span>");
      

  5.   

            private static void TestRegex08()
            {
                string html = @"document.write(""ddddddddd"");
    document.write(""ddddddddd"");
    document.write('ddddddddd');";
                string result = Regex.Replace(html, @"document.write\((['""])((?:\\.|[^\\'""])+)\1\);", "document.writeln(\"<p>$2</p>\");");
                Console.WriteLine(result);
            }result是你要的?
    输出document.writeln("<p>ddddddddd</p>");
    document.writeln("<p>ddddddddd</p>");
    document.writeln("<p>ddddddddd</p>");
      

  6.   

    不好意思,可能我没有讲清楚,就是用正则把document.writeln("<p>dfdfdf<\/p>");
    document.writeln("fdfdfdf");
    document.writeln("<span>dfdfdfdgg<\/span>");
    转换成 HTML 代码