[New-bugs-announce] [issue35543] re.sub is only replacing max. of 2 string found by regexp.

Sagar report at bugs.python.org
Thu Dec 20 03:26:30 EST 2018


New submission from Sagar <sagardhiman19 at gmail.com>:

Below are the logs:

>>> dat = '"10GE" "4x" "AMPC" "B3" "BUILTIN" "DOWN" "LU" "SFP+" "ether" "xe" "DOWN" "MPC" "BUILTIN"'
>>> type = re.subn(r'\"BUILTIN\"|\"B\d\"|\"I\d\"|\"LU\"|\"Trinity\"|\"Trio\"|\"DOWN\"|\"UNKNOWN\"|'
...     r'^AND$|\"Q\"|\"MPC\"|\"EA\d\"|\"3D\"', '', dat, re.I)
>>> type
('"10GE" "4x" "AMPC"   "DOWN" "LU" "SFP+" "ether" "xe" "DOWN" "MPC" "BUILTIN"', 2)
>>> dat = '"10GE" "4x" "AMPC"   "DOWN" "LU" "SFP+" "ether" "xe" "DOWN" "MPC" "BUILTIN"'
>>> type = re.subn(r'\"BUILTIN\"|\"B\d\"|\"I\d\"|\"LU\"|\"Trinity\"|\"Trio\"|\"DOWN\"|\"UNKNOWN\"|'
...     r'^AND$|\"Q\"|\"MPC\"|\"EA\d\"|\"3D\"', '', dat, re.I)
>>> type
('"10GE" "4x" "AMPC"     "SFP+" "ether" "xe" "DOWN" "MPC" "BUILTIN"', 2)
>>> dat = '"10GE" "4x" "AMPC"     "SFP+" "ether" "xe" "DOWN" "MPC" "BUILTIN"'
>>> type = re.subn(r'\"BUILTIN\"|\"B\d\"|\"I\d\"|\"LU\"|\"Trinity\"|\"Trio\"|\"DOWN\"|\"UNKNOWN\"|'
...     r'^AND$|\"Q\"|\"MPC\"|\"EA\d\"|\"3D\"', '', dat, re.I)
>>> type
('"10GE" "4x" "AMPC"     "SFP+" "ether" "xe"   "BUILTIN"', 2)
>>> dat = '"10GE" "4x" "AMPC"     "SFP+" "ether" "xe"   "BUILTIN"'
>>> type = re.subn(r'\"BUILTIN\"|\"B\d\"|\"I\d\"|\"LU\"|\"Trinity\"|\"Trio\"|\"DOWN\"|\"UNKNOWN\"|'
...     r'^AND$|\"Q\"|\"MPC\"|\"EA\d\"|\"3D\"', '', dat, re.I)
>>> type
('"10GE" "4x" "AMPC"     "SFP+" "ether" "xe"   ', 1)
>>>

----------
components: Library (Lib)
messages: 332198
nosy: saga
priority: normal
severity: normal
status: open
title: re.sub is only replacing max. of 2 string found by regexp.
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35543>
_______________________________________


More information about the New-bugs-announce mailing list