recording data between [ and ]

Roy Smith roy at panix.com
Thu Apr 21 11:23:49 EDT 2005


Diez B. Roggisch <deetsNOSPAM at web.de> wrote:
>> Yes, it does... may take me a few minutes to get my head around it
>> though. Why do re's have to be so arcane and complicated... especially
>> in Python?
>> 
>> It's hard to preach 'ease of use' with stuff such as this in the
>> language. Perhaps one day it can be rolled up into something that
>> *really* is easy to understand:
>
>Welcome to the wonderful world of programming. Regular expressions are what
>they are because they are modeled after a certain theory - that of finite
>state automata and their correspondence to certain classes of
>grammars.

Another way to look at it is that RE's are a programming language of
their own, and Python just provides an interface to it, just like it
provides interfaces to databases, network protocols, and operating
systems.

RE's predate Python by many years (at least as far back as the early
70's in a form we would recognize today), and have evolved over the
decades to become more powerful.  Unfortunately, with power came
arcane syntax.  On the good side, most of the time you can use a
smallish subset of the full RE syntax and still have some pretty
powerfull pattern matching.

Python's motto is "there's one way to do it".  Sometimes that means
"let's do it the way everybody else does it instead of reinventing it
ourselves".  The Python RE module is certainly an example of that.

BTW, there's a pretty good Wikipedia article on RE's
(http://en.wikipedia.org/wiki/Regular_expression).



More information about the Python-list mailing list