怎样消除fck 的结果中的
....
html标签

malun666 2010-08-31 04:12:45
怎样消除fck 的结果中的<div>....</div> html标签 。
要求:去掉后,输出到word后,样式基本不变,最基本的换行总有吧。只是去掉标签,已经实现【用正则表达式】,但是输出到word后格式却。。。都是内容紧贴着,没有换行以及格式了。。。
...全文
279 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
hzexe 2010-08-31
  • 打赏
  • 举报
回复

String xx=Regex.Replace(源字符,@"<div[^>]*>([\s\S]*?)</div>","<p>$1</p>");
malun666 2010-08-31
  • 打赏
  • 举报
回复
public static string StripHTML(string HTML) //google "StripHTML" 得到
{
string[] Regexs = {
@"<script[^>]*?>.*?</script>",
@"<(\/\s*)?!?((\w+:)?\w+)(\w+(\s*=?\s*(([""'])(\\[""'tbnr]|[^\7])*?\7|\w+)|.{0})|\s)*?(\/\s*)?>",
@"([\r\n])[\s]+",
@"&(quot|#34);",
@"&(amp|#38);",
@"&(lt|#60);",
@"&(gt|#62);",
@"&(nbsp|#160);",
@"&(iexcl|#161);",
@"&(cent|#162);",
@"&(pound|#163);",
@"&(copy|#169);",
@"&#(\d+);",
@"-->",
@"<!--.*\n"
};

string[] Replaces ={
"",
"",
"",
"\"",
"&",
"<",
">",
" ",
"\xa1", //chr(161),
"\xa2", //chr(162),
"\xa3", //chr(163),
"\xa9", //chr(169),
"",
"\r\n",
""
};
string s = HTML;
for (int i = 0; i < Regexs.Length; i++)
{
s = new Regex(Regexs[i], RegexOptions.Multiline | RegexOptions.IgnoreCase).Replace(s, Replaces[i]);
}
s.Replace("<", "");
s.Replace(">", "");
s.Replace("\r\n", "");
return s;
}


这是消除html标签的。但是消除后,内容全部连一块了。
jackyzsy2008 2010-08-31
  • 打赏
  • 举报
回复
为啥要消除呢?留着挺好的
wuyq11 2010-08-31
  • 打赏
  • 举报
回复
替换HTML
Regex.Replace(str,@"<[^> ]+>","");
换行使用Enviroment.NewLine,\r\n替换标识
保存为HTML
malun666 2010-08-31
  • 打赏
  • 举报
回复
谁有好的解决方法吗?急用!
<html> <head> <FCK:meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>隐藏在网页一侧的隐现效果QQ在线客服</title> </head> <body> <!-- 左隐藏菜单开始 --> [removed] function move(x, y) { if (document.all) { object1.style.pixelLeft += x; object1.style.pixelTop += y;} else if (document.layers) { document.object1.left += x; document.object1.top += y; }}; function position() { document.object1.left += -200; document.object1.top += 0; document.object1.visibility = "show" }; function makeStatic() { if (document.all) {object1.style.pixelTop=document.body.scrollTop+100} else {eval('document.object1.top=eval(window.pageYOffset+20)');} setTimeout("makeStatic()",0);} [removed] <!-- 左隐藏菜单结束 --> <!-- 左隐藏菜单BIG --> <layer class="NS" 0)" top="20" visibility="hide" name="object1" left="0"> [removed] if (document.all) [removed]('<DIV ID="object1" : Absolute ;Left : -125px ;Top : 20px ;Width : 0px ;Z-Index : 20">') [removed] [removed] <!-- if (document.all||document.layers) makeStatic(); if (document.layers) { window.onload=position; } var sitems=new Array(); var sitemlinks=new Array(); function hl(n) { n.className='hl'} function n(h) { h.className='n'} //-->[removed]
<style type="text/css">BODY { MARGIN: 0px } </style>
fcksavedurl="http://img.lingd.net/attachments/date_201102/aec0566ca67d631a05c6371d905b0444.jpg" width="118" border="0" name="servicepic_01">
fcksavedurl="http://img.lingd.net/attachments/date_201102/b09c649fa63f400276c530ff82f7fb57.jpg" width="14" border="0" name="servicepic_02"> 点击这里给我发消息 fcksavedurl="http://img.lingd.net/attachments/date_201102/6a056f029f18421e1c130ba09ec31f6b.jpg" width="15" border="0" name="servicepic_04">
fcksavedurl="http://img.lingd.net/attachments/date_201102/156e2b1e482d3c50069d1e565110c687.jpg" width="118" border="0" name="servicepic_05">
fcksavedurl="http://img.lingd.net/attachments/date_201102/b09c649fa63f400276c530ff82f7fb57.jpg" width="14" border="0" name="servicepic_06"> 点击这里给我发消息 fcksavedurl="http://img.lingd.net/attachments/date_201102/6a056f029f18421e1c130ba09ec31f6b.jpg" width="15" border="0" name="servicepic_08">
 
站点留言簿
 
fcksavedurl="http://img.lingd.net/attachments/date_201102/60be137e9207567cd639387dad5bc73b.gif" width="118" border="0" name="servicepic_09">
fcksavedurl="http://img.lingd.net/attachments/date_201102/63cf41be3abae4a74d4fcb3e58e8473b.gif" width="20">
[removed] if (document.all) [removed]('DIV>') [removed] </layer> <!-- 左隐藏菜单END --> </body> </html>

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧