Help: Arbitrary number of groups in regex
Duncan Booth
duncan at NOSPAMrcp.co.uk
Mon Aug 12 05:09:38 EDT 2002
bokr at oz.net (Bengt Richter) wrote in news:aj1de2$cj3$0 at 216.39.172.122:
> But why the big reaction against regex? Not as efficient? If so, why
> not ? (assuming it's compiled outside of a loop, so the setup overhead
> is divided by the loop count to get the comparable single-operation
> cost).
My reaction isn't against regex, it is against the inappropriate use of
regular expressions. Regular expressions are essential in many situations,
but over-using them for all text manipulation can produce code that is
unclear and hard to maintain.
Efficiency isn't an issue, at least not until you have found that your code
is too slow and profiled it to verify where the bottleneck lies.
If you visit
<http://groups.google.co.uk/groups?threadm=Xns912D652C43500duncanrcpcouk%40
127.0.0.1>
then you will find quite a long thread from this newsgroup last year
discussing a situation where regular expressions might be used, and
possible reasons for preferring or avoiding them (I'm referring to the
entire thread here although the link points to one of my postings 13
messages into the discussion).
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list