"Zeroing out" the Nth group in a RE

holger krekel pyth at devel.trillke.net
Sun Aug 4 18:09:40 CEST 2002


Greg Chapman wrote:
> On Sat, 3 Aug 2002 17:41:18 +0200 (MET DST), Doru-Catalin Togea
> <doru-cat at ifi.uio.no> wrote:
> 
> >bibleRef =
> >re.compile(r'(?:(?:(\w+)(?:\s+)(\d+):(\d+))(?:(?:\s*)(?:-)(?:\s*)(\d+))?)')
> >m = bibleRef.findall(refs)
> >print m
> >
> >outputs:
> >	
> >[('gen', '5', '17', '23'), ('lev', '14', '20', '23'), ('rev', '19', '10',
> >'25')]
> >
> >which is "mistaken" in that the second tuple should have been 
> >
> >	('lev', '14', '20') 		or 
> >	('lev', '14', '20', '')
> 
> 
> Which version of Python are you using?  This appears to work correctly using
> 2.2.1:
> 
> Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import re
> >>> refs = 'gen  5:17 - 23  , lev 14:20, rev 19:10 - 25'

historical research in 3050 will have problems interpreting the
reference to bible parts in this (c.l.py) context. 




More information about the Python-list mailing list