Dennis Lee Bieber wrote: > On 25 Sep 2006 10:25:01 -0700, "codefire" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > >> Yes, I didn't make it clear in my original post - the purpose of the >> code was to learn something about regexps (I only started coding Python >> last week). In terms of learning "a little more" the example was >> successful. However, creating a full email validator is way beyond me - >> the rules are far too complex!! :) >> > > I've been doing small things in Python for over a decade now > (starting with the Amiga port)... > > I still don't touch regular expressions... They may be fast, but to > me they are just as much line noise as PERL... I can usually code a > partial "parser" faster than try to figure out an RE. > If I may add another thought along the same line: regular expressions seem to tend towards an art form, or an intellectual game. Many discussions revolving around regular expressions convey the impression that the challenge being pursued is finding a magic formula much more than solving a problem. In addition there seems to exist some code of honor which dictates that the magic formula must consist of one single expression that does it all. I suspect that the complexity of one single expression grows somehow exponentially with the number of functionalities it has to perform and at some point enters a gray zone of impending conceptual intractability where the quest for the magic formula becomes particularly fascinating. I also suspect that some problems are impossible to solve with a single expression and that no test of intractability exists other than giving up after so many hours of trying. With reference to the OP's question, what speaks against passing his texts through several simple expressions in succession? Speed of execution? Hardly. The speed penalty would not be perceptible. Conversely, in favor of multiple expressions speaks that they can be kept simple and that the performance of the entire set can be incrementally improved by adding another simple expression whenever an unexpected contingency occurs, as they may occur at any time with informal systems. One may not win a coding contest this way, but saving time isn't bad either, or is even better.
Frederic -- http://mail.python.org/mailman/listinfo/python-list