Iterating with multiple matches (regular expressio

Results 1 to 2 of 2

Thread: Iterating with multiple matches (regular expressio

  1. #1
    Join Date
    Dec 1969

    Default Iterating with multiple matches (regular expressio

    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 (regular expre

    I&#039;m not fully sure what you mean , but remember you can iterate thro the matches collection without using the &#039;for...each&#039; statement, try this :<BR><BR>for i = 1 to colMatches.count<BR> allmatches = allmatches & colMatches(i-1)<BR> if i mod 2 = 0 then allmatches = allmatches & "&#060; br&#062;<BR>"<BR>next<BR><BR>HTH<BR><BR>--<BR>Anglo Saxon

Posting Permissions

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