This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: sub function would not work without the flags but the search would work fine
Type: Stage: resolved
Components: Regular Expressions Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: bayat, ezio.melotti, mrabarnett
Priority: normal Keywords:

Created on 2020-09-11 17:12 by bayat, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg376734 - (view) Author: ali (bayat) Date: 2020-09-11 17:12
it would work like this sub("pattern","replace", txt, flags= re.IGNORECASE | re.DOTALL)
but it wouldnt work like this  sub("pattern","replace", txt, re.IGNORECASE | re.DOTALL)
msg376736 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2020-09-11 18:10
The arguments are: re.sub(pattern, repl, string, count=0, flags=0).

Therefore:

    re.sub("pattern","replace", txt, re.IGNORECASE | re.DOTALL)

is passing re.IGNORECASE | re.DOTALL as the count, not the flags.

It's in the documentation and the interactive help.
History
Date User Action Args
2022-04-11 14:59:35adminsetgithub: 85930
2020-09-11 18:10:33mrabarnettsetstatus: open -> closed
resolution: not a bug
messages: + msg376736

stage: resolved
2020-09-11 17:12:58bayatcreate