New submission from Bnaya <[email protected]>:
I was writing the following:
re.search('([+-*])', "54 * 83")
And I got the following runtime error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\re.py",
line 183, in search
return _compile(pattern, flags).search(string)
File "C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\re.py",
line 286, in _compile
p = sre_compile.compile(pattern, flags)
File
"C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\sre_compile.py",
line 764, in compile
p = sre_parse.parse(p, flags)
File
"C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\sre_parse.py",
line 930, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File
"C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\sre_parse.py",
line 426, in _parse_sub
not nested and not items))
File
"C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\sre_parse.py",
line 816, in _parse
p = _parse_sub(source, state, sub_verbose, nested + 1)
File
"C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\sre_parse.py",
line 426, in _parse_sub
not nested and not items))
File
"C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\sre_parse.py",
line 580, in _parse
raise source.error(msg, len(this) + 1 + len(that))
re.error: bad character range +-* at position 2
Note that for different operators order, such as:
re.search('([+*-])', "54 * 83")
or
re.search('([*+-])', "54 * 83")
the function worked just fine.
----------
components: Regular Expressions
messages: 326716
nosy: Bnaya, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: re.error - for the search function in the re module
type: crash
versions: Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue34851>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com