I need some help with a regexp please

D

Dennis Lee Bieber

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.
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
C

codefire

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.

Yes, it seems to me that REs are a bit "hit and miss" - the only way to
tell if you've got a RE "right" is by testing exhaustively - but you
can never be sure.... They are fine for simple pattern matching though.
 
F

Frederic Rentsch

Dennis said:
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
 
F

Fredrik Lundh

Frederic said:
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.

hear! hear!

for dense guys like myself, regular expressions work best if you use
them as simple tokenizers, and they suck pretty badly if you're trying
to use them as parsers.

and using a few RE:s per problem (or none at all) is a perfectly good
way to get things done.

</F>
 
C

codefire

for dense guys like myself, regular expressions work best if you use
them as simple tokenizers, and they suck pretty badly if you're trying
to use them as parsers.

:) Well, I'm with you on that one Fredrik! :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,294
Latest member
LandonPigo

Latest Threads

Top