[issue32998] regular expression regression in python 3.7

2018-03-05 Thread Doug Hellmann
Change by Doug Hellmann : -- nosy: +doughellmann ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.

[issue32998] regular expression regression in python 3.7

2018-03-05 Thread mike bayer
mike bayer added the comment: for those watching this would be the findall() case which is consistent between pythons: import re for reg in [ 'VARCHAR(30) COLLATE "en_US"', 'VARCHAR(30)' ]: print(re.findall(r'(?: COLLATE.*)?$', reg)) output (all pythons): [' COLLATE "en_US"',

[issue32998] regular expression regression in python 3.7

2018-03-05 Thread mike bayer
mike bayer added the comment: for now the quickest solution is to add "count=1" so that it only replaces once. -- ___ Python tracker ___ ___

[issue32998] regular expression regression in python 3.7

2018-03-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: In your case you can just pass 1 as the fourth parameter of re.sub(). -- ___ Python tracker ___

[issue32998] regular expression regression in python 3.7

2018-03-05 Thread mike bayer
mike bayer added the comment: also, removing the "?" is not an option for me. I need the brackets to be placed prior to the "COLLATE" subsection, but unconditionally even if the "COLLATE" section is not present. Looking at the change the behavior seems wrong to me. The regexp states,

[issue32998] regular expression regression in python 3.7

2018-03-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Just see the re.sub() documentation for 3.7. There is also a note in the What's New document, in the "Changes in the Python API" section. -- ___ Python tracker ___

[issue32998] regular expression regression in python 3.7

2018-03-05 Thread mike bayer
mike bayer added the comment: can you point me to the documentation? -- ___ Python tracker ___ ___ Python-bugs-list mailing list Uns

[issue32998] regular expression regression in python 3.7

2018-03-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This is intentional change. Prior to 3.7 re.sub() didn't replace empty matches adjacent to a previous non-empty match. In 3.7 it does. Together with other changes this made all four functions that search multiple matches of the pattern (re.findall(), re.fi

[issue32998] regular expression regression in python 3.7

2018-03-05 Thread mike bayer
mike bayer added the comment: correction, that's fedora 26, not 27 -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsub

[issue32998] regular expression regression in python 3.7

2018-03-05 Thread mike bayer
New submission from mike bayer : demo: import re inner = 'VARCHAR(30) COLLATE "en_US"' result = re.sub( r'((?: COLLATE.*)?)$', r'FOO\1', inner ) print(inner) print(result) in all Python versions prior to 3.7: VARCHAR(30) COLLATE "en_US" VARCHAR(30)FOO COLLATE "en_US" i