HTML轉(zhuǎn)換為UBB代碼
當前位置:點晴教程→知識管理交流
→『 技術(shù)文檔交流 』
過ubb轉(zhuǎn)換為html,但是沒有見過反過來用的吧?其實有些時候還真有用。比如采集到的文章,里面都是html格式化的,但是要入庫到只能使用ubb的論壇貼吧程序怎么辦?[br]通過下面這個函數(shù),搞定![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 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |