首页 > Web开发 > 详细

VBS教程:VBscript属性-Length 属性

时间:2016-02-09 00:26:11      阅读:178      评论:0      收藏:0      [点我收藏+]

Length 属性

返回在字符串搜索中找到的匹配的长度。

object.Length

object 参数总是一个 Match 对象。

说明

下面的代码说明了 Length 属性的用法:

Function RegExpTest(patrn, strng)  Dim regEx, Match, Matches      ‘ 建立变量。  Set regEx = New RegExp         ‘ 建立正则表达式。  regEx.Pattern = patrn         ‘ 设置模式。  regEx.IgnoreCase = True         ‘ 设置是否区分大小写。  regEx.Global = True         ‘ 设置全程可用性。  Set Matches = regEx.Execute(strng)   ‘ 执行搜索。  For Each Match in Matches      ‘ 遍历 Matches 集合。    RetStr = RetStr & "匹配 " & I & " 位于 "    RetStr = RetStr & Match.FirstIndex & "。匹配的长度为"    RetStr = RetStr & Match.Length     RetStr = RetStr & "个字符。" & vbCRLF  Next  RegExpTest = RetStrEnd FunctionMsgBox(RegExpTest("is.", "IS1 is2 IS3 is4"))

VBS教程:VBscript属性-Length 属性

原文:http://www.jb51.net/article/4530.htm

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!