急请教如何用asp删除word生成的html中的垃圾代码。

maximon 2004-01-08 03:57:25
另外csdn发布文档中图片的处理是怎么做的?
...全文
85 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Jaron 2004-01-09
  • 打赏
  • 举报
回复
http://www.jaron.cn/chs_scripts/52/2003-12/20031229130805-101441.html

<script language=javascript>
<!--
function cleanWordString( html ) {
html = html.replace(/<\/?SPAN[^>]*>/gi, "" );// Remove all SPAN tags
html = html.replace(/<(\w[^>]*) class=([^ ¦>]*)([^>]*)/gi, "<$1$3") ; // Remove Class attributes
//html = html.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ; // Remove Style attributes
html = html.replace(/<(\w[^>]*) lang=([^ ¦>]*)([^>]*)/gi, "<$1$3") ;// Remove Lang attributes
html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;// Remove XML elements and declarations
html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;// Remove Tags with XML namespace declarations: <o:p></o:p>
html = html.replace(/ /, " " );// Replace the
// Transform <P> to <DIV>
var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ; // Different because of a IE 5.0 error
html = html.replace( re, "<div$2</div>" ) ;
//insertHTML( html ) ;
test.b.value = html
}
//-->
</script>
<form id=test>
<textarea name=a cols=60 rows=13></textarea><br>
<textarea name=b cols=60 rows=13 ID="b"></textarea>
<input type=button onclick="cleanWordString(test.a.value);" value=转换>
</form>
yangzixp 2004-01-08
  • 打赏
  • 举报
回复
多研究一下word的垃圾信息,把有规律的删除就可以了。
lang11zi 2004-01-08
  • 打赏
  • 举报
回复
塞选
xieyj 2004-01-08
  • 打赏
  • 举报
回复
使用 mid 截取字符串

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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