[Python-ideas] New pattern-matching library (was: str.split with multiple individual split characters)
Ka-Ping Yee
python at zesty.ca
Mon Feb 28 19:53:28 CET 2011
On Mon, 28 Feb 2011, Guido van Rossum wrote:
> On Mon, Feb 28, 2011 at 8:04 AM, Mike Meyer <mwm at mired.org> wrote:
>> Possibly we should investigate adding one of those to the standard
>> library, along with a cross-reference from the regexp documentation?
>
> It's been tried before without much success. I think it may have been
> a decade ago that Ka-Ping Yee created a pattern matching library that
> used function calls (and operator overloading? I can't recall) to
> generate patterns -- compiling to re patterns underneath. It didn't
> get much use.
Yes, there was operator overloading. The expressions looked like this:
letter + 3*digits + anyspace + either(some(digits), some(letters))
If anyone is curious, the module is available here:
http://zesty.ca/python/rxb.py
You're welcome to experiment with it, modify it, use it as a starting
point for your own pattern matcher if you like.
--Ping
More information about the Python-ideas
mailing list