循环ASP中的两个正则表达式

时间:2012-06-12 06:54:55

标签: regex asp-classic pattern-matching

Function VeriBul(BaslangicDegeri,BitisDegeri)

  Set RegEx = New RegExp
  RegEx.IgnoreCase = True
  RegEx.Global = True
  RegEx.Pattern = "(" & BaslangicDegeri & ")(.+?)(" & BitisDegeri & ")"
  Set Sonuc = RegEx.Execute(Mid(strRetval,29600,254000))

  For Each i in Sonuc
 VeriBul =  VeriBul & tr2(i.SubMatches(1))

    Set RegEx2 = New RegExp
    RegEx2.IgnoreCase = True
    RegEx2.Global = True
    RegEx2.Pattern = "(<hemenalfiyat>)(.+?)(</hemenalfiyat>)"
    Set Sonucx = RegEx2.Execute(Mid(strRetval,33000,2000))

     For Each y in Sonucx
     VeriBul2 =  VeriBul2 & tr2(y.SubMatches(1))
     Next

     When it works then appering error

  Next

=============================================== =======

For Each i in Sonuc
  i.SubMatches(1)

For Each y in Sonucx
  y.SubMatches(1)

  Next
  Next

如何打印除Submatches代码之外的其他内容?因为我有两个正则表达式代码(因此我用作Regex2),我不能再次使用Submatches了。

谢谢,

1 个答案:

答案 0 :(得分:0)

如果没有剩下的代码(tr2)以及输入和所需的输出,很难解决这个问题,但我猜你的代码应该是这样的

Function VeriBul(BaslangicDegeri,BitisDegeri)

  Set RegEx = New RegExp
  RegEx.IgnoreCase = True
  RegEx.Global = True
  RegEx.Pattern = "(" & BaslangicDegeri & ")(.+?)(" & BitisDegeri & ")"

  Set RegEx2 = New RegExp
  RegEx2.IgnoreCase = True
  RegEx2.Global = True
  RegEx2.Pattern = "(<hemenalfiyat>)(.+?)(</hemenalfiyat>)"

  Set Sonuc = RegEx.Execute(Mid(strRetval,29600,254000))
  Set Sonucx = RegEx2.Execute(Mid(strRetval,33000,2000))

  For Each i in Sonuc
    VeriBul =  VeriBul & tr2(i.SubMatches(1))
  Next
  For Each y in Sonucx
   VeriBul =  VeriBul & tr2(y.SubMatches(1))
  Next

Next