Dive Into Python: call for comments (long)

Steve Lamb grey at despair.rpglink.com
Mon Apr 23 20:48:24 EDT 2001


On Mon, 23 Apr 2001 18:50:23 -0400, Mark Pilgrim <f8dy at diveintopython.org>
wrote:
>romanNumeralPattern = \
>    re.compile('^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$')

>Is this more efficient?  It is more elegant (as regular expressions go)?
>Any regular expression experts care to comment?

    Well, generally {}'s are less efficient but a little easier to read.
OTOH, define "efficiency" as "easier to read" and yes, it is.  

    The only other thing my admittedly limited regex mind can see is changing
the ()s to be (?:)s unless you're explcitely matching them for later use.  But
I'm sure many people will take issue to that for a variety of good reasons.
:)

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
         ICQ: 5107343          | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------



More information about the Python-list mailing list