chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] regex and named subpatterns


From: Robin Lee Powell
Subject: Re: [Chicken-users] regex and named subpatterns
Date: Wed, 5 Mar 2008 17:49:10 -0800
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

On Wed, Mar 05, 2008 at 08:42:23PM -0500, Hans Nowak wrote:
> Hi,
>
> In Python (and Perl, etc) it's possible to name subpatterns (or "groups") 
> in a regular expression.  For example:
>
> In [1]: import re
>
> In [2]: s = "the quick brown fox"
>
> In [3]: rx = re.compile("(?P<foo>quick)")

I've just looked through "man perlre" fairly carefully and found
nothing like this at all.  So I asked the Python regex
documentation:

    Python adds an extension syntax to Perl's extension syntax. If
    the first character after the question mark is a "P", you know
    that it's an extension that's specific to Python. Currently
    there are two such extensions: (?P<name>...) defines a named
    group, and (?P=name) is a backreference to a named group. If
    future versions of Perl 5 add similar features using a different
    syntax, the re module will be changed to support the new syntax,
    while preserving the Python-specific syntax for compatibility's
    sake.

So, I'm afraid you're SOL.

-Robin

-- 
Lojban Reason #17: http://en.wikipedia.org/wiki/Buffalo_buffalo
Proud Supporter of the Singularity Institute - http://singinst.org/
http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]