内容显示页
 
类别:ASP+VBS | 浏览(140) | 2007-2-28 15:28:00 | 关闭广告

<script language ="vbs">
'函数名称:RegExpTest
'参数: strng--》要处理的字符串;patrn--》以|隔开的各种结尾标志如:<br/>|</p>|<br>; patrn2--》要替换成的字符串,也以|隔开 
'作者:柳永法(yongfa365)'Blog
'网址:http://www.yongfa365.com/item/0046b03419ad59dc.html
'功能:将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.cbdcn.com|http://www.yongfa365.com/blog|hi.baidu.com/yongfa365" 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>

引用本页地址:http://www.yongfa365.com/item/0046b03419ad59dc.html
 
 
相关链接
 
网友评论:
姓名: 记住我
网址:
邮箱:
内容:
验证码:  验证码图片看不清? 换张图试试
 
   
 
 
文章分类
 
   

Power by :柳永法(yongfa365)'Blog | Model by :hibaidu | CSS by:众网友 | 京ICP备07011491号  QQ:64049027  E-mail:64049027qq.com

本空间赞助商:北京中科兴联信息技术有限公司