当前位置: 首页 > 图文教程 > 脚本技术 > VBScript > VBS教程:方法-Execute 方法

VBScript
VBS教程:函数-LoadPicture 函数
VBS教程:函数-Len 函数
VBS教程:函数-Left 函数
VBS教程:函数-LCase 函数
VBS教程:函数-LBound 函数
VBS教程:函数-Join 函数
VBS教程:函数-IsObject 函数
VBS教程:函数-IsNumeric 函数
VBS教程:函数-IsNull 函数
VBS教程:函数-IsEmpty 函数
VBS教程:函数-IsDate 函数
VBS教程:函数-IsArray 函数
VBS教程:函数-Int、Fix 函数
VBS教程:函数-InStrRev 函数
VBS教程:函数-InStr 函数
VBS教程:函数-InputBox 函数
VBS教程:函数-Hour 函数
VBS教程:函数-Hex 函数
VBS教程:函数-GetRef 函数
VBS教程:函数-GetObject 函数

VBScript 中的 VBS教程:方法-Execute 方法


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

Execute 方法

对指定的字符串执行正则表达式搜索。

object.Execute(string)

参数

object

必选项。总是一个 RegExp 对象的名称。

string

必选项。要在其上执行正则表达式的文本字符串。

说明

正则表达式搜索的设计模式是通过 RegExp 对象的 Pattern 来设置的。

Execute 方法返回一个 Matches 集合,其中包含了在 string 中找到的每一个匹配的 Match 对象。如果未找到匹配,Execute 将返回空的 Matches 集合。

下面的代码说明了 Execute 方法的用法。

Function RegExpTest(patrn, strng) Dim regEx, Match, Matches ' Create variable. Set regEx = New RegExp ' Create a regular expression. regEx.Pattern = patrn ' Set pattern. regEx.IgnoreCase = True ' Set case insensitivity. regEx.Global = True ' Set global applicability. Set Matches = regEx.Execute(strng) ' Execute search. For Each Match in Matches ' Iterate Matches collection. RetStr = RetStr & "Match found at position " RetStr = RetStr & Match.FirstIndex & ". Match Value is '" RetStr = RetStr & Match.Value & "'." & vbCRLF Next RegExpTest = RetStrEnd FunctionMsgBox(RegExpTest("is.", "IS1 is2 IS3 is4"))