[issue22760] re.sub does only first 16 replacements if re.S is used

2014-10-29 Thread STINNER Victor

Changes by STINNER Victor :


--
resolution: not a bug -> duplicate
superseder:  -> re.sub confusion between count and flags args

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22760] re.sub does only first 16 replacements if re.S is used

2014-10-29 Thread Ezio Melotti

Ezio Melotti added the comment:

See #11957.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22760] re.sub does only first 16 replacements if re.S is used

2014-10-29 Thread STINNER Victor

STINNER Victor added the comment:

This bug report is common. An enhancement would be to make the count parameter 
a keyword only parameter. Would it break a lot of code?

--
nosy: +haypo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22760] re.sub does only first 16 replacements if re.S is used

2014-10-29 Thread Georg Brandl

Georg Brandl added the comment:

The fourth parameter is not "flags", but "count", the max. number of 
substitutions.  "flags" is the fifth parameter, or give it as a keyword 
argument.

--
nosy: +georg.brandl
resolution:  -> not a bug
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22760] re.sub does only first 16 replacements if re.S is used

2014-10-29 Thread Peter Otten

Peter Otten added the comment:

This is not a bug; the signature of re.sub() is

sub(pattern, repl, string, count=0, flags=0)

and the fourth argument thus the 'count' delimiting the number of substitutions 
that you accidentally specify as

>>> import re
>>> re.S
16

I recommend that you use a keyword arg to fix your code:

>>> re.sub('x', 'a', "x"*20, flags=re.S)
''

--
nosy: +peter.otten

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22760] re.sub does only first 16 replacements if re.S is used

2014-10-29 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22760] re.sub does only first 16 replacements if re.S is used

2014-10-29 Thread Michael Del Monte

New submission from Michael Del Monte:

Easily reproduced:

re.sub('x', 'a', "x"*20, re.S)

returns ''

--
components: Regular Expressions
messages: 230216
nosy: ezio.melotti, mgdelmonte, mrabarnett
priority: normal
severity: normal
status: open
title: re.sub does only first 16 replacements if re.S is used
type: behavior
versions: Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com