Re: Regex optimization
- From: "Chuck B" <chuckb@xxxxxxxx>
- Date: Wed, 26 Sep 2007 11:52:47 -0400
"Chris Shepherd" <chsh@xxxxxxxxxxxxxx> wrote in message
news:%23HGhWfEAIHA.968@xxxxxxxxxxxxxxxxxxxxxxx
Chuck B wrote:
Yes I will - but then that won't tell me much about what went on
internally.
I was hoping that someone with knowledge of the Regex engine could help
me understand why one was better than the other.
Thanks for your help. Oh wait... nm... ;)
Trying it for yourself and seeing the results is a perfectly reasonable
answer.
I have to disagree here. Trying it for myself will give me numbers but not
understanding which is the untimate goal.
While it may not allow you to recreate the source code, it certainly will
tell you which way is more efficient. Because your original regexes were
completely unequal, it's hard to say whether you could actually learn
anything about what is going on "internally" since in one instance you'd
get a LOT more hits than the other.
Assuming a somewhat normal dataset where some records have "The quick
brown fox" and more records have "The" in them, I'd suggest that it's
probably more work to return more results than it is simply to find them,
so #1 wins out. On 10,000 lines of "The quick brown fox" where the
returned values would be equal, I'd wager on the second regex being faster
(equal time spent returning values, less time spent searching).
The fault here is mine for not explaining adequately what I wanted.
In the case above I'm looking for the special case where there is 1 match
per string for either Regex. For instance; the result of running both
examples above against "09/26/07 The quick brown fox ran away."
The date would probably take just as long for each regex. However, it seems
like it might be more efficient with the static characters to search for a
longer string than a shorter one (assuming that there was no match embedded
inside of another match). The reason for the increase is that the pointer
pointing to the head of the search would move a greater length after a
successful match.
.
- Follow-Ups:
- Re: Regex optimization
- From: Jesse Houwing
- Re: Regex optimization
- References:
- Regex optimization
- From: Chuck B
- Re: Regex optimization
- From: Stephany Young
- Re: Regex optimization
- From: Chuck B
- Re: Regex optimization
- From: Chris Shepherd
- Regex optimization
- Prev by Date: Re: Filtering ListViewItems
- Next by Date: Re: Best way to code the following
- Previous by thread: Re: Regex optimization
- Next by thread: Re: Regex optimization
- Index(es):