Skip to content

oddity with regular expressions and ipython #1142

@sagetrac-mabshoff

Description

@sagetrac-mabshoff

Reported by wjp: The following is an example from the python regular expression howto. It seems that ipython's preprocessing somehow gets in the way. This works perfectly fine with regular python:

[wjp@issa sage-2.8.12]$ ./sage
----------------------------------------------------------------------
| SAGE Version 2.8.12, Release Date: 2007-11-06                      |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------

sage: import re
sage: >>> p = re.compile('(a(b)c)d')
sage: >>> m = p.match('abcd')
sage: >>> m.group(0)
---------------------------------------------------------------------------
<type 'exceptions.IndexError'>            Traceback (most recent call last)

/data/sage/sage-2.8.12/<ipython console> in <module>()

<type 'exceptions.IndexError'>: no such group
sage: type(m)
<type '_sre.SRE_Match'>
sage: m.groups()
('abc', 'b')
sage: 

Cheers,

Michael

Component: packages: standard

Issue created by migration from https://trac.sagemath.org/ticket/1142

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions