Message142511
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 |
|
Date |
User |
Action |
Args |
2011-08-20 03:13:59 | angelonuffer | set | recipients:
+ angelonuffer |
2011-08-20 03:13:59 | angelonuffer | set | messageid: <1313810039.38.0.201023108206.issue12789@psf.upfronthosting.co.za> |
2011-08-20 03:13:58 | angelonuffer | link | issue12789 messages |
2011-08-20 03:13:58 | angelonuffer | create | |
|