New submission from Ângelo Otávio Nuffer Nunes <angelonuf...@gmail.com>:
When I use the scanner object in re module, I can create groups on regex and associate this to a method... In [17]: re.Scanner([(r"(\w)(\w)\w", foo)]) Out[17]: <re.Scanner instance at 0x15c4e60> But I tryed 3 groups and it raises "invalid SRE code", but I think my regex is not wrong... In [15]: scan = re.Scanner([(r"(\w)(\w)(\w)", foo)]) --------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) /home/angelo/<ipython console> in <module>() /usr/lib/python2.7/re.pyc in __init__(self, lexicon, flags) 305 s.groups = len(p)+1 306 p = sre_parse.SubPattern(s, [(BRANCH, (None, p))]) --> 307 self.scanner = sre_compile.compile(p) 308 def scan(self, string): 309 result = [] /usr/lib/python2.7/sre_compile.pyc in compile(p, flags) 520 return _sre.compile( 521 pattern, flags | p.pattern.flags, code, 522 p.pattern.groups-1, --> 523 groupindex, indexgroup 524 ) RuntimeError: invalid SRE code ---------- components: Regular Expressions messages: 142511 nosy: angelonuffer priority: normal severity: normal status: open title: re.Scanner don't support more then 2 groups on regex type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12789> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com