From 7cafe4d7e466996d5fc32e871fe834e0e0c94282 Mon Sep 17 00:00:00 2001 From: Fredrik Lundh Date: Sun, 2 Jul 2000 17:33:27 +0000 Subject: - actually enabled charset anchors in the engine (still not used by the code generator) - changed max repeat value in engine (to match earlier array fix) - added experimental "which part matched?" mechanism to sre; see http://hem.passagen.se/eff/2000_07_01_bot-archive.htm#416954 or python-dev for details. --- Lib/sre_parse.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'Lib/sre_parse.py') diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index b2632563c7..81ca217a47 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -451,6 +451,23 @@ def _parse(source, state): if gid is None: raise error, "unknown group name" subpattern.append((GROUP, gid)) + elif source.match("#"): + index = "" + while 1: + char = source.get() + if char is None: + raise error, "unterminated index" + if char == ")": + break + index = index + char + try: + index = int(index) + if index < 0 or index > MAXREPEAT: + raise ValueError + except ValueError: + raise error, "illegal index" + subpattern.append((INDEX, index)) + continue else: char = source.get() if char is None: -- cgit v1.2.1