[New-bugs-announce] [issue19408] Regex with set of characters and groups raises error

Isis Binder report at bugs.python.org
Sat Oct 26 14:53:41 CEST 2013


New submission from Isis Binder:

I was working on some SPOJ exercises when the regex module hit me with an error related to '*' being used inside the character set operator.

I looked in the module docs but it says: Special characters lose their special meaning inside sets. For example, [(+*)] will match any of the literal characters '(', '+', '*', or ')'.

Traceback attached.

Offending code (inside IDLE):
import re
a = '73479*5152'
re.match(r'(\d+)([+-*])(\d+)', a).groups()

NOTE: if I write r'(\d+)([*])(\d+)', r'(\d+)([*+-])(\d+)' or r'(\d+)([+*-])(\d+)' it works. Shouldn't it simply work as described in the docs or should the docs be updated with an entry about proper character ordering in the character class?

----------
components: Regular Expressions
files: traceback.txt
messages: 201351
nosy: Isis.Binder, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: Regex with set of characters and groups raises error
type: crash
versions: Python 3.3
Added file: http://bugs.python.org/file32372/traceback.txt

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19408>
_______________________________________


More information about the New-bugs-announce mailing list