Re: Regex optimization

Tech-Archive recommends: Fix windows errors by optimizing your registry



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.

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).

Chris.
.