On Jul 3, 2008, at 1:56 PM, IanSR wrote:
> I have just tested the following example re code in sage, and it fails > both on a Linux install and a Mac OS X install: > > import re > p = re.compile('(a(b)c)d') > m = p.match('abcd') > m.group(0) > # expect: 'abcd' > m.group(1) > # expect: 'abc' > m.group(2) > # expect: 'b' > > This is take from: > > http://www.amk.ca/python/howto/regex/ > > What's going on? Does sage have some special version of the re module > that doesn't support pattern groups? The problem is related to preparsing. This will work: import re p = re.compile('(a(b)c)d') m = p.match('abcd') m.group(int(0)) Your original code gets preparsed into the following: import re p = re.compile('(a(b)c)d') m = p.match('abcd') m.group(Integer(0)) And I suppose the group() method doesn't know how to handle Integers correctly, which is strange, since I thought this is what the __index__() method is for.... david --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---