HTML转换为UBB代码
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
过ubb转换为html,但是没有见过反过来用的吧?其实有些时候还真有用。比如采集到的文章,里面都是html格式化的,但是要入库到只能使用ubb的论坛贴吧程序怎么办?[br]通过下面这个函数,搞定![br]
[img]images/code.gif[/img] 程序代码 <% [br]function html2ubb(l1) [br]if len(trim(l1))>0 then [br]else [br]exit function [br]end if [br]dim l4,i1,i2,i3 [br]dim i,i4:i4=array(16,19,21,24,32,45) [br]i1=l1 [br]set i2=new regexp [br]i2.global=true [br]i2.ignorecase=true'忽略大小写 [br]i2.pattern="/r":i1=i2.replace(i1,"") [br]i2.pattern="on(load|click|dbclick|mouseover|mousedown|mouseup)=""[^""]+""":i1=i2.replace(i1,"") [br]i2.pattern="":i1=i2.replace(i1,"") [br]i2.pattern="]+href=""([^""]+)""[^>]*>(.*?)":i1=i2.replace(i1,"[追梦url=$1]$2[/url追梦]") [br]i2.pattern="]+color=([^ >]+)[^>]*>(.*?)":i1=i2.replace(i1,"[color=#01]$2[/color]") [br]i2.pattern="]+src=""([^""]+)""[^>]*>":i1=i2.replace(i1,"[追梦img]$1[/img追梦]") [br]i2.pattern="<([/]?)b>":i1=i2.replace(i1,"[$1b]") [br]i2.pattern="<([/]?)strong>":i1=i2.replace(i1,"[$1b]") [br]i2.pattern="<([/]?)u>":i1=i2.replace(i1,"[$1u]") [br]i2.pattern="<([/]?)i>":i1=i2.replace(i1,"[$1i]") [br]i2.pattern=" ":i1=i2.replace(i1," ") [br]i2.pattern="&":i1=i2.replace(i1,"&") [br]i2.pattern="""":i1=i2.replace(i1,"""") [br]i2.pattern="<":i1=i2.replace(i1,"<") [br]i2.pattern=">":i1=i2.replace(i1,">") [br]i2.pattern=" ":i1=i2.replace(i1,vbcrlf) [br]i2.pattern="<[^>]*?>":i1=i2.replace(i1,"") [br]i2.pattern=" +":i1=i2.replace(i1,vbcrlf) [br]set i2=nothing [br]html2ubb=i1 [br]end function [br]response.write html2ubb("追梦阳光") [br]%> 该文章在 2010/7/22 18:30:33 编辑过 |
关键字查询
相关文章
正在查询... |