栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP > 正则表达

jb51用的ubb转换 原创

正则表达 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

jb51用的ubb转换 原创

ubbcode.asp
复制代码 代码如下:
<%
Function UBBCode(strContent)
If isEmpty(strContent) Or isNull(strContent) Then
Exit Function
Else
dim regex,strMatch
set regex=new RegExp
regex.IgnoreCase =True
regex.Global=True
regex.Pattern="[html]((rn)?([sS]+?))[/html]"
Set strMatchs=regex.Execute(strContent)
For Each strMatch in strMatchs
'response.write strMatch.SubMatches(3)
Randomize
rndID="runcode"&Int(100000 * Rnd)
strContent=Replace(strContent,strMatch.Value,"
HTML代码:"&UBBFilter(HTMLDecode(strMatch.SubMatches(2)))& "
  
 [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]")
Next
Set strMatchs=nothing
'去空行
regex.pattern="n[s]*r"
Set strMatchs=regex.Execute(strContent)
For Each strMatch in strMatchs
strContent=Replace(strContent,strMatch.Value,"")
Next
'代码块
regex.Pattern="[code]((rn)?([sS]+?))[/code]"
Set strMatchs=regex.Execute(strContent)
For Each strMatch in strMatchs
Randomize
rndID="code"&Int(100000 * Rnd)
strContent=Replace(strContent,strMatch.Value,"
CODE代码:[复制此代码]
"&strMatch.SubMatches(2)&"")
Next
Set strMatchs=nothing
'实现插入影音文件
regex.Pattern="[(swf|wma|wmv|rm|ra|qt)(=d*?|)(,d*?|)]([^<>]*?)[/(swf|wma|wmv|rm|ra|qt)]"
Set strMatchs=regex.Execute(strContent)
dim strType,strWidth,strHeight,strSRC,TitleText
        For Each strMatch in strMatchs
            RAndomize
              strType=strMatch.SubMatches(0)
              if strType="swf" then
               TitleText="Flash动画"
              elseif strType="wma" then
               TitleText="播放音频文件"
              elseif strType="wmv" then
               TitleText="播放视频文件"         
              elseif strType="rm" then
               TitleText="播放real视频流文件"         
              elseif strType="ra" then
               TitleText="播放real音频流文件"         
              elseif strType="qt" then
               TitleText="播放mov视频文件"         
              end if
              strWidth=strMatch.SubMatches(1)
              strHeight=strMatch.SubMatches(2)
              if (len(strWidth)=0) then 
                strWidth="400"
                else
               strWidth=right(strWidth,(len(strWidth)-1))
              end if
              if (len(strHeight)=0) then
               strHeight="300"
                else
              strHeight=right(strHeight,(len(strHeight)-1))
              end if
              strSRC=strMatch.SubMatches(3)
            rndID="temp"&Int(100000 * Rnd)
            strContent= Replace(strContent,strMatch.Value,""&TitleText&"在线播放")
        Next
        Set strMatchs=nothing
        regex.Pattern="([mid])(.[^]]*)[/mid]"
        strContent= regex.Replace(strContent,"")
regex.pattern="
([s| | ]*)?
"
strContent=regex.replace(strContent,"
")
strContent=replace(strContent,"&","&")
strContent=replace(strContent,"'","'")
strContent=replace(strContent,"","") '因为以前上传图片

set regex=nothing
end if
UBBCode=strContent
end function
%>

基本上来自pjhome
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/60928.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号