Index: src//Doc/lib/libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.100 diff -u -r1.100 libre.tex --- src//Doc/lib/libre.tex 13 May 2003 14:40:24 -0000 1.100 +++ src//Doc/lib/libre.tex 14 Jun 2003 05:32:42 -0000 @@ -297,6 +297,15 @@ fixed length. Patterns which start with negative lookbehind assertions may match at the beginning of the string being searched. +\item[\code{(?(\var{id/name})yes-pattern|no-pattern)}] Will try to match +with \regexp{yes-pattern} if the group with given \var{id} or \var{name} +exists, and with \regexp{no-pattern} if it doesn't. \regexp{|no-pattern} +is optional and can be omitted. For example, +\regexp{(<)?(\e w+@\e w+(?:\e .\e w+)+)(?(1)>)} is a poor email matching +pattern, which will match with \code{''} as well as +\code{'user@host.com'}, but not with \code{' codeyes codeno ... */ + i = pattern[0]; + { + SRE_CHAR* p = (SRE_CHAR*) state->mark[i+i]; + SRE_CHAR* e = (SRE_CHAR*) state->mark[i+i+1]; + if (!p || !e || e < p) { + pattern += pattern[1]; + break; + } + } + pattern += 2; + break; + case SRE_OP_LITERAL_IGNORE: TRACE(("|%p|%p|LITERAL_IGNORE %d\n", pattern, ptr, pattern[0])); if (ptr >= end || Index: src//Modules/sre_constants.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre_constants.h,v retrieving revision 2.15 diff -u -r2.15 sre_constants.h --- src//Modules/sre_constants.h 19 Apr 2003 12:56:08 -0000 2.15 +++ src//Modules/sre_constants.h 14 Jun 2003 05:33:09 -0000 @@ -11,7 +11,7 @@ * See the _sre.c file for information on usage and redistribution. */ -#define SRE_MAGIC 20030419 +#define SRE_MAGIC 20030614 #define SRE_OP_FAILURE 0 #define SRE_OP_SUCCESS 1 #define SRE_OP_ANY 2 @@ -26,23 +26,24 @@ #define SRE_OP_BIGCHARSET 11 #define SRE_OP_GROUPREF 12 #define SRE_OP_GROUPREF_IGNORE 13 -#define SRE_OP_IN 14 -#define SRE_OP_IN_IGNORE 15 -#define SRE_OP_INFO 16 -#define SRE_OP_JUMP 17 -#define SRE_OP_LITERAL 18 -#define SRE_OP_LITERAL_IGNORE 19 -#define SRE_OP_MARK 20 -#define SRE_OP_MAX_UNTIL 21 -#define SRE_OP_MIN_UNTIL 22 -#define SRE_OP_NOT_LITERAL 23 -#define SRE_OP_NOT_LITERAL_IGNORE 24 -#define SRE_OP_NEGATE 25 -#define SRE_OP_RANGE 26 -#define SRE_OP_REPEAT 27 -#define SRE_OP_REPEAT_ONE 28 -#define SRE_OP_SUBPATTERN 29 -#define SRE_OP_MIN_REPEAT_ONE 30 +#define SRE_OP_GROUPREF_EXISTS 14 +#define SRE_OP_IN 15 +#define SRE_OP_IN_IGNORE 16 +#define SRE_OP_INFO 17 +#define SRE_OP_JUMP 18 +#define SRE_OP_LITERAL 19 +#define SRE_OP_LITERAL_IGNORE 20 +#define SRE_OP_MARK 21 +#define SRE_OP_MAX_UNTIL 22 +#define SRE_OP_MIN_UNTIL 23 +#define SRE_OP_NOT_LITERAL 24 +#define SRE_OP_NOT_LITERAL_IGNORE 25 +#define SRE_OP_NEGATE 26 +#define SRE_OP_RANGE 27 +#define SRE_OP_REPEAT 28 +#define SRE_OP_REPEAT_ONE 29 +#define SRE_OP_SUBPATTERN 30 +#define SRE_OP_MIN_REPEAT_ONE 31 #define SRE_AT_BEGINNING 0 #define SRE_AT_BEGINNING_LINE 1 #define SRE_AT_BEGINNING_STRING 2