您的位置:首页 > 编程语言 > VB

VBScript 实现 UBB 显示代码([code][/code])附加行号, 正则实现 By Stabx

2006-06-16 18:41 701 查看
标题: VBScript 实现 UBB 显示代码(
)附加行号, 正则实现 By Stabx

正文:

QUOTE:

VBScript 实现 UBB 显示代码(
)附加行号, 正则实现 By Stabx

完成了, 实现这个该死的功能有几小时丢了...

作用: 显示 UBB 代码时, 加上行号. [↓下面代码显示区就是]
此功能由 正则实现替换, ol li 标签实现显示效果, li 标签 属性设置为 list-style-type:decimal;
那些行号只是一个显示, 不是一个实在的号码, 就一障眼法.

1. 替换 UBB
 为 HTML 标签
2. 解密 内容为 UBB 
 标签
3. 相关 CSS
话外音: 秩序就是一切, 不是我喜欢把内容弄得一塌糊涂, 而是 CSDN 的编辑器太东施...

shawl.qiu<shawl.qiuATgmail.com>
绿色学院 | http://blog.csdn.net/btbtd/
2006-6-16
CODE:


----3. 相关 CSS

----------------------------------------

<style type="text/css">

/*<![CDATA[*/ 

/* UBB */

ol {margin:0px; padding:0px;}

code, quote, cite {

    line-height: 150%;

    }

.u_code, .marginE, .u_quote, .marginQuote, .u_cite, .cite {

    padding:15px 10px;

    margin:0px auto;

    overflow:auto;

    width:90%;

    font-size: 12px;

    line-height:150%;

    }

.u_code, .marginE {

    color: #3333FF;

    border: 1px dotted #000000;

    }

.u_quote, .marginQuote{

    color: #CC3366;

    border: 1px dotted #FF9900;

    }

.u_cite, .cite {

    border: 1px dotted #CCCCCC;

    font-style:normal;

    }

.u_code ol li { list-style-type:decimal; color:blue !important;}

.u_code ol {margin:0px 0px 0px 28px;}

 /*]]>*/

</style>

----------------------------------------

----2. 解密 内容为 UBB
 标签

----------------------------------------

    Set re1 = New regExp

        re1.Global = true

        re1.IgnoreCase = true

        re1.Multiline = true

            re1.Pattern = "<p/><b>CODE:</b><code><div class=""u_code""><ol>(?:[/s/S]+)</ol></div></code>"  

        Set Matches = re1.Execute(str)

            for each match in Matches

                match=replace(match,"<p/><b>CODE:</b><code><div class=""u_code""><ol>","")                 match=replace(match,"</ol></div></code>","")                 match=replace(match,"<li>","")                 match=replace(match,"</li>","")

                re1.Pattern = "<p/><b>CODE:</b><code><div class=""u_code""><ol>(?:[/s/S]+)</ol></div></code>"  

                str = re1.Replace(str,"
"&match&"
")

            next

    set    re1=nothing

----------------------------------------

----1. 替换 UBB
 为 HTML 标签

----------------------------------------

    Set re1 = New regExp

        re1.Global = true

        re1.IgnoreCase = true

        re1.Multiline = true

            re1.Pattern = "/[code/]([?:/s/S]+)/[//code/]"  

        Set Matches = re1.Execute(str)

            for each match in Matches

                match=replace(match,"<br/>","")                 match=replace(match,"
","")

                match=replace(match,"
","")

                

                re1.Pattern = "(^[/s/S]?)"

                match = re1.Replace(match,"<li>$1")

                

                re1.Pattern = "([/s/S]$)"

                match = re1.Replace(match,"$1</li>")

 

                re1.Pattern = "/[code/][/s/S]+/[//code/]"  

                str = re1.Replace(str,"<p/><b>CODE:</b><code><div class=""u_code""><ol>"&match&"</ol></div></code>")

            next

    set    re1=nothing

----------------------------------------
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  vbscript border 解密 html css