如何把js用正则转成HTML代码 像这样的一段document.write("ddddddddd");document.write("ddddddddd");document.write('ddddddddd'); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 html是什么样子?<p>ddddddd</p>这样? string result = Regex.Replace(html,@"document.write\((['"])((?:\\.|[^\\'"])+)\1\);","<p>$2</p>");result就是结果,不过不知道是不是就是你期望的。如果不是,跟帖说明。 string result = Regex.Replace(html,@"document.write\((['""])((?:\\.|[^\\'""])+)\1\);","<p>$2</p>"); 不好意思,应该是这种格式的:document.writeln("<p>dfdfdf<\/p>");document.writeln("fdfdfdf");document.writeln("<span>dfdfdfdgg<\/span>"); 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>"); 不好意思,可能我没有讲清楚,就是用正则把document.writeln("<p>dfdfdf<\/p>");document.writeln("fdfdfdf");document.writeln("<span>dfdfdfdgg<\/span>");转换成 HTML 代码 vs2008视图设计器的奇怪问题! 哪位知道怎么恢复啊? 菜鸟求助老鸟如何学习C#以及C#的一些专业书 Calendar怎么设置属性为必填 高分,跪着爬着求代码,C#改变桌面背景图片. 请教高手 C#中为什么要出现接口(interface)这个概念呢? 后台线程计算完成后如何通知主线程弹出窗口? 我想要mainMenu控件某一列里面的內容是從据庫里面取出來的﹐怎么弄? C#新手求助 关于DLL文件 算法问题,请高手指点,很急,在线等候,马上给分! 以遇上麻烦了,怎么统计到这些记录,请大家都进来看看! 一个菜鸟的问题...
<p>ddddddd</p>
这样?
如果不是,跟帖说明。
不好意思,应该是这种格式的:document.writeln("<p>dfdfdf<\/p>");
document.writeln("fdfdfdf");
document.writeln("<span>dfdfdfdgg<\/span>");
{
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>");
document.writeln("fdfdfdf");
document.writeln("<span>dfdfdfdgg<\/span>");
转换成 HTML 代码