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

ASP
ASP编程中15个非常有用的例子 (二)
ASP与JSP的比较(一)
ASP与JSP的比较(二)
ASP中五种连接数据库的方法
从ASP调用SQL中的图像
用排序串字段实现树状结构(例程:连接字串)
用排序串字段实现树状结构(例程:删除贴子)
用排序串字段实现树状结构(例程:回复表单)
用排序串字段实现树状结构(例程:显示贴子内容)
用排序串字段实现树状结构(例程:显示树)
用排序串字段实现树状结构(存储过程)
用排序串字段实现树状结构(库结构)
用排序串字段实现树状结构(原理)
remote script文档(转载自微软)(一)
remote script文档(转载自微软)(二)
remote script文档(转载自微软)(三)
remote script文档(转载自微软)(四)
remote script文档(转载自微软)(五)
remote script文档(转载自微软)(六)
remote script文档(转载自微软)(七)

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 214 ::
收藏到网摘: 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>