[New-bugs-announce] [issue29959] re.match failed to match left square brackets as the first char

bo qu report at bugs.python.org
Sat Apr 1 03:38:49 EDT 2017


New submission from bo qu:

if "[" is the first char in a string, then re.match can't match any pattern from the string, but re.findall works fine

details as follows:

[da at namenode log]$ python3
Python 3.4.3 (default, Jun 14 2015, 14:23:40) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> cyzd="[abc]"
>>> cyzd
'[abc]'
>>> pattern="ab(.*)"
>>> pattern
'ab(.*)'
>>> match=re.match(pattern, cyzd)
>>> match
>>> pattern=r'ab(.*)'     
>>> re.findall(pattern, cyzd)
['c]']

----------
components: Regular Expressions
messages: 290968
nosy: bo qu, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: re.match failed to match left square brackets as the first char
type: behavior
versions: Python 3.5

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


More information about the New-bugs-announce mailing list