当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP,vbs正则轮翻在文章段落后加上网址等内容

ASP
ASP系列讲座(十)ASP 内建对象
ASP系列讲座(十一)ActiveX 组件
ASP系列讲座(十二)向浏览器发送内容
ASP系列讲座(十三)向浏览器传送脚本
ASP系列讲座(十四)包含文件
ASP系列讲座(十五)使用 HTML 表格
ASP系列讲座(十六)访问数据库
ASP系列讲座(十七)调试 ASP 脚本
ASP系列讲座(十八)管理应用程序
ASP系列讲座(十九)管理会话
ASP系列讲座(二十)维护 ASP 应用程序的安全
ASP系列讲座(二十一)创建事务性脚本
ASP系列讲座(二十二)使用国际站点
ASP系列讲座(二十三)编写跨平台应用程序
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (一)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (二)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (三)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (四)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (五)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (六)

ASP,vbs正则轮翻在文章段落后加上网址等内容


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 244 ::
收藏到网摘: n/a

ASP,vbs正则轮翻在文章段落后加上网址,网站名称,网站介绍等内容 <script language ="vbs">
'函数名称:RegExpTest
'参数: strng--》要处理的字符串;patrn--》以|隔开的各种结尾标志如:<br/>|</p>|<br>; patrn2--》要替换成的字符串,也以|隔

'作者:柳永法(yongfa365)'Blog
'功能:将strng字符串内的以patrn结束的字符后边随机的加上patrn2里的内容
Function RegExpTest(strng, patrn, patrn2)
Dim regEx, Match, Matches ' 建立变量。
Set regEx =New RegExp ' 建立正 则表达式。
regEx.IgnoreCase =True' 设置是否区分字符大小写。
regEx.Global =True' 设置全局可用性。
patrn = Split(patrn,"|")
ForEach p in patrn
regEx.Pattern = p ' 设置模式。
strng = regEx.Replace(strng,"||"& Chr(10)& p)
Next
strng = Split(strng,"||")
ForEach E in strng
s = s + E + arrArt(patrn2)
Next
RegExpTest = s
EndFunction
Function arrArt(patrn2)
arrArti = Split(patrn2,"|")
Randomize
arrArt = arrArti(CInt(UBound(arrArti)* Rnd))
EndFunction

strng ="111<br/>222</p>333<br/>444</p>555<Br>666</P>111"
Source = strng
patrn ="<br/>|</p>|<br>"
patrn2 ="www.xiaoshuo8.net|http://www.ruanchen.com/"
words = RegExpTest(strng, patrn, patrn2)
MsgBox(words)
</script>
<script>
document.Write "<fieldset><legend>原字符串</legend>"+ Source +"</fieldset><br>"
document.Write "<fieldset><legend>转换后字符串</legend>"+ words +"</fieldset><br>"
</script>