On Thu, Jul 3, 2008 at 10:56 AM, IanSR <[EMAIL PROTECTED]> 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 that the group method gets confused
by Sage integers instead of just casting to an int.
Just explicitly cast to an int to get things to work:
sage: m.group(int(0))
'abcd'
sage: type(0)
<type 'sage.rings.integer.Integer'>
William
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---