Iterating with multiple matches

Results 1 to 2 of 2

Thread: Iterating with multiple matches

  1. #1
    Join Date
    Dec 1969

    Default Iterating with multiple matches

    &nbsp;<BR><BR>I have a reg ex pattern like so.. <BR><BR>objRegExpr.pattern="MoreInfo(&#039;([0-9]{12})&#124([^]*)" <BR><BR><BR>This creates two matches which can be refered to like so.. <BR><BR>$1 <BR>$2 <BR><BR>How can I iterate through the collection while keeping both matches on the same line? <BR><BR>If I iterate through using FOR EACH I get- <BR><BR><BR>"html stuff here then $1 (variable)" <BR><BR>"html stuff here then $2 (variable)" <BR><BR><BR>Instead of... <BR><BR>"html stuff here then $1 $2 (variable)" <BR><BR><BR><BR>Here is my code if you want to take a peak.. <BR><BR><BR><BR>RefPage = " =&miles=&itemname=&sortby=city&School=1&PrivSchool =1&College=1&Library=1&Status=Search+Finished&Reco rds=0"<BR><BR>Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")<BR> objXMLHTTP.Open "GET", RefPage, False<BR> objXMLHTTP.Send<BR> <BR>RefPage = objXMLHTTP.responseText<BR>quote = chr(34)<BR><BR>Set objRegExpr = New regexp<BR> objRegExpr.Global = True<BR> objRegExpr.IgnoreCase = True<BR> objRegExpr.pattern="([0-9]{12})&#124([^&#062;&#060;B&#062;]*)&#060;/B&#062;&#060;/A&#062;"<BR> Set colMatches = objRegExpr.Execute(RefPage)<BR> <BR><BR>Dim allMatches <BR>allmatches="" <BR>For Each colMatch In colMatches <BR>allmatches = allmatches + colmatch.value + "<BR>" + VBcrlf<BR>Next<BR><BR><BR>Response.Write objRegExpr.Replace(allmatches,"$1")<BR><BR>%&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: Iterating with multiple matches

    i&#039;m not sure exactly what your asking for...<BR>it&#039;s look like your code is 99% correct.<BR>is this what you wanted?<BR><BR>Dim allMatches <BR>allmatches="" <BR>For Each colMatch In colMatches <BR> allmatches = allmatches + colmatch.value + ", "<BR>Next<BR><BR>Response.Write "html stuff here then" & allmatches<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts