Re: New pattern-matching library (was: str.split
with multiple individual split characters)
[Posted March 2, 2011 by corbet]
| From: |
| Ka-Ping Yee <python-XLawsxctnuM-AT-public.gmane.org> |
| To: |
| Guido van Rossum <guido-+ZN9ApsXKcEdnm+yROfE0A-AT-public.gmane.org> |
| Subject: |
| Re: New pattern-matching library (was: str.split
with multiple individual split characters) |
| Date: |
| Mon, 28 Feb 2011 10:53:28 -0800 (PST) |
| Message-ID: |
| <alpine.DEB.1.00.1102281050270.14734@holly.lfw.org> |
| Cc: |
| python-ideas-+ZN9ApsXKcEdnm+yROfE0A-AT-public.gmane.org |
| Archive-link: |
| Article, Thread
|
On Mon, 28 Feb 2011, Guido van Rossum wrote:
> On Mon, Feb 28, 2011 at 8:04 AM, Mike Meyer <mwm-tkOQc4lHIczYtjvyW6yDsg@public.gmane.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
(
Log in to post comments)