Features
Ask DevGuru
ASP Resources
Find the Bug
Knowledge Base
Links
Tips of the Week
Tutorials
Products
dgCalendar
dgCharge New!
dgChart New!
dgFileUpload
dgReport New!
dgSort
dgTree
Site
Authoring
Coming Soon
DevGuru Resume
Link to Us
Merchandise
Sponsorships
Testimonials
What's New
Technologies
ADO 2.6
ASP
CSS2
HTML
JavaScript
Jet SQL
Transact-SQL Syntax
VBScript
WML
WMLScript
WSH
XML DOM
All Methods
Match Object
Matches Collection
Properties
METHOD: object.Execute
Implemented in version 5.0
object.
Execute
(TargetString)
The
Execute
method is used with a
RegExp
object variable to look for a search string pattern (also known as a regular expression) inside a target string.
There is one mandatory argument, the target string to be searched. The search string pattern (regular expression) is declared using the
Pattern
property.
Each time a match is made (i.e., the search pattern is found inside the target string), a
Match
object is created and added to a
Matches
collection. Note that a match does not have to occur. Therefore the
Execute
method can return a
Matches
collection that is empty, or that contains one or more, objects.
Code:
<%
'this sub finds the matches
Sub RegExpTest(strMatchPattern, strPhrase)
'create variables
Dim objRegEx, Match, Matches, StrReturnStr
'create instance of RegExp object
Set objRegEx = New RegExp
'set the pattern
objRegEx.Pattern = strMatchPattern
'create the collection of matches
Set Matches = objRegEx.Execute(strPhrase)
'print out all matches
For Each Match in Matches
strReturnStr = "Match found at position "
strReturnStr = strReturnStr & Match.FirstIndex & ". Match Value is `"
strReturnStr = strReturnStr & Match.value & "'."
'print
Response.Write(strReturnStr & "<BR>")
Next
End Sub
'call the subroutine
RegExpTest "is.", "Is1 is2 Is3 is4"
%>
Output:
Match found at position 4. Match Value is `is2'.
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information