by purewater · 15y ago · 0 comments
To run a regular expression, you have to search through the entire corpus.
Right now, when you type a search in, it searches through its index to look only through the top documents that match those words.
My guess is that it would be more like 1000000x slower.
I even guess that, if someone actually built an engine that handled all regular expressions and found out a way to handle DDOS attacks, people would complain that they want more (no, you cannot parse HTML with regular expressions)
The fact is though, that searching a body of text with an arbitrary regular expression is an O(n) operation. And with the entire Web, O(n) is infeasible to do for every search. And it is O(n) only if you mean regular expression in the narrow technical sense. I believe that the best current algorithms for extended regular expressions (e.g. the ones in Perl) which support features like back-references are exponential in the worst case.