|
From: | Hans Nowak |
Subject: | [Chicken-users] Re: regex and named subpatterns |
Date: | Wed, 05 Mar 2008 21:55:21 -0500 |
User-agent: | Thunderbird 2.0.0.0 (Macintosh/20070326) |
Robin Lee Powell wrote:
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.
It's no big deal, I don't really use it a lot personally, I just wondered if the feature was there. The way I understand it, Chicken's regex module is based on PCRE, and the PCRE manual mentions the (?P<name>...) syntax:
In PCRE, a subpattern can be named in one of three ways: (?<name>...) or (?'name'...) as in Perl, or (?P<name>...) as in Python. References to capturing parentheses from other parts of the pattern, such as back- references, recursion, and conditions, can be made by name as well as by number. (At least according to http://www.pcre.org/pcre.txt.)It's a bit odd though that Chicken (maybe unintentionally) supports the construct in regular expressions, but provides no ways to make use of it.
--Hans
[Prev in Thread] | Current Thread | [Next in Thread] |