查看文章
 
ASP正则对象总结
2007年12月19日 星期三 9:35
1.建立正则对象
Set regEx=New RegExp ‘建立正则对象
属性:
regEx.Pattern=vpattern ‘获取正则表达式
regEx.IgnoreCase=True ‘是否区分大小写匹配
regEx.Global=True ‘是否进行全局匹配
方法:
Set Matches=regEx.Execute(str) ‘对str进行搜索,返回匹配到的Matches集合   
regEx.Replace(str1,str2) ‘用str2替换 str1中匹配到的字符串
regEx.Test(str) ‘测试str中是否有符合匹配,有则返回True

2.集合对象(Matches)的使用
Set Matches=regEx.Execute(str) ‘对str进行搜索,返回匹配到的Matches集合
属性:
Matches.Count ‘匹配到的个数
Matches.Item(i) ‘第i个匹配到的字符串
注意:Matches.Item(i)=Matches(0).Value=Matches(I)
方法: 无
3.单个集合对象(Match)的使用
‘ 其实就是Matches集合中的单个匹配到的对象,通过For Each……Next得到
For Each Match In Matches
    Match.FirstIndex ‘属性,返回在搜索字符串中匹配的位置
    Match.Length ‘属性,匹配的字符串的长度
    Match.Value ‘属性,返回在一个搜索字符串中找到的匹配的值或文本
Next
‘Match中还存在一个SubMatches集合
Match.SubMatches.Count ‘ 属性,匹配个数
Match.SubMatches.Item(I) ‘属性,某个匹配


类别:asp相关技术文章||添加到搜藏 |分享到i贴吧|浏览(1653)|评论 (0)
 
 
最近读者:
 
网友评论:
本篇日志被作者设置为禁止发表新评论

   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu