Regular Expressions and performance.
From: terje (nidaros2001_at_hotmail.com)
Date: 06/01/04
- Next message: Dib: "How to Call MS Access Form through VB 6"
- Previous message: Ye Zanxiong: "vb project can not loaded in windows98-"Out of Memory""
- Next in thread: terje: "Re: Regular Expressions and performance."
- Reply: terje: "Re: Regular Expressions and performance."
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 01 Jun 2004 16:07:14 +0200
In my project I am downloading html files and parsing them using the
Regular Expressions vbscript 5.5 object from VB6.
I have read somewhere that it is wise to first test to see if there are
anything to parse at all by using the Test method before calling the
Execute method because there is supposed to be a performance benefit in
this. But this must assume that the Test Method is parsing the file in a
different and much faster way than the Execute Method? If I want to parse
out the <title> tag from a html file and it is present then I have to seek
the string twice, right? So maybe the Test method is good only when you
are parsing out many items, not just one or a few? Here's some code:
oRegEx.Pattern = "<input([^>]*)>"
sColor = "#F5DEB3"
If (oRegEx.Test(m_sParsedHtml) = True) Then
m_sParsedHtml = oRegEx.Replace(m_sParsedHtml, "[?{![span
style=""background-color: " & sColor & """]!}?]<input$1>[?{![/span]!}?]")
End If
Does this code make any sense or should I cut out the Test part?
And what about this scenario where I use Test together with a Match
Collection:
If (oRegEx.Test(m_sParsedHtml) = True) Then
Set colMatches = oRegEx.Execute(m_sParsedHtml)
For Each oMatch In colMatches
sList = (sList & oMatch.Value & ",")
Next
I guess what I am asking is if someone have done some speed tests on this
object and perhaps have a link or two..?
terje
- Next message: Dib: "How to Call MS Access Form through VB 6"
- Previous message: Ye Zanxiong: "vb project can not loaded in windows98-"Out of Memory""
- Next in thread: terje: "Re: Regular Expressions and performance."
- Reply: terje: "Re: Regular Expressions and performance."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|