[Python-ideas] Proposed convenience functions for re module
Steven D'Aprano
steve at pearwood.info
Thu Jul 23 01:31:47 CEST 2009
On Thu, 23 Jul 2009 07:38:11 am Mark Dickinson wrote:
> Steven, could you show some examples of real(ish)-world use-cases
> for one or both of these functions? Preferably including the code
> that might directly follow a multimatch or multisearch call.
I'm afraid that I don't use regexes anywhere near enough to champion
this proposal in the face of serious opposition, or even skepticism. If
this isn't a simple enough "no-brainer", then I'm going to have to pass
the baton onto somebody else (assuming anyone actually likes this
idea).
This idea came about from the thread started by Sean Reifschneider,
proposing adding regexes to strings. I thought (and Sean seemed to
agree) that these convenience functions would solve his primary
use-case. So this proposal isn't scratching an itch I have.
> It's probably because I haven't used regexes widely enough, but
> in all the potential examples I can come up with, either
>
> (1) the regexes are similar enough that they can be refactored into
> a single regex (e.g., just concatenated with '|'), or
>
> (2) they're distinct enough that each regex needs its own handing,
> so that the multimatch/multisearch would need to be followed by
> a multiway 'if/elif/else' anyway; in this case, it seems that little
> is gained.
These are both reasonable approaches. This proposal isn't supposed to
solve every multiple-regex-handling problem.
So far support for this has been luke-warm. If anyone really likes this
idea, please speak up, otherwise I'll let it drop.
--
Steven D'Aprano
More information about the Python-ideas
mailing list