M
mike
Hello,
I'm trying to write a function to return submatches. I want to do this
because I want to run a match on matches of matches of yet other
matches, so it seemed to me it would be easier to work with if there
was one line of code that would return a collection or array of
matches. Here's what I got:
<%
Dim objRegExp
Set objRegExp = New RegExp
Dim objMatches, objMatch
Set submatches = getsubmatches("this should hopefully match and print
eight words", "(\w)", TRUE, TRUE)
For i = 0 To submatches.Count - 1
response.write "<br>" & submatches(i)
Next
Function getsubmatches(strText, pattern, isGlobal, ignoreCase)
Dim data
'Set our pattern
objRegExp.Pattern = pattern
objRegExp.IgnoreCase = ignoreCase
objRegExp.Global = isGlobal
For Each objMatch in objRegExp.Execute(strText)
getsubmatches = objMatch.SubMatches
Next
End Function
%>
I get:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment
/getsubmatches.asp, line 22
thats this line: "getsubmatches = objMatch.SubMatches"
Can anyone help me write this correctly?
I'm trying to write a function to return submatches. I want to do this
because I want to run a match on matches of matches of yet other
matches, so it seemed to me it would be easier to work with if there
was one line of code that would return a collection or array of
matches. Here's what I got:
<%
Dim objRegExp
Set objRegExp = New RegExp
Dim objMatches, objMatch
Set submatches = getsubmatches("this should hopefully match and print
eight words", "(\w)", TRUE, TRUE)
For i = 0 To submatches.Count - 1
response.write "<br>" & submatches(i)
Next
Function getsubmatches(strText, pattern, isGlobal, ignoreCase)
Dim data
'Set our pattern
objRegExp.Pattern = pattern
objRegExp.IgnoreCase = ignoreCase
objRegExp.Global = isGlobal
For Each objMatch in objRegExp.Execute(strText)
getsubmatches = objMatch.SubMatches
Next
End Function
%>
I get:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment
/getsubmatches.asp, line 22
thats this line: "getsubmatches = objMatch.SubMatches"
Can anyone help me write this correctly?