Skip to content

sub function would not work without the flags but the search would work fine #85930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bayat mannequin opened this issue Sep 11, 2020 · 2 comments
Closed

sub function would not work without the flags but the search would work fine #85930

bayat mannequin opened this issue Sep 11, 2020 · 2 comments
Labels

Comments

@bayat
Copy link
Mannequin

bayat mannequin commented Sep 11, 2020

BPO 41764
Nosy @ezio-melotti

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2020-09-11.18:10:33.855>
created_at = <Date 2020-09-11.17:12:58.342>
labels = ['expert-regex', 'invalid', '3.8']
title = 'sub function would not work without the flags but the search would work fine'
updated_at = <Date 2020-09-11.18:10:33.854>
user = 'https://bugs.python.org/bayat'

bugs.python.org fields:

activity = <Date 2020-09-11.18:10:33.854>
actor = 'mrabarnett'
assignee = 'none'
closed = True
closed_date = <Date 2020-09-11.18:10:33.855>
closer = 'mrabarnett'
components = ['Regular Expressions']
creation = <Date 2020-09-11.17:12:58.342>
creator = 'bayat'
dependencies = []
files = []
hgrepos = []
issue_num = 41764
keywords = []
message_count = 2.0
messages = ['376734', '376736']
nosy_count = 3.0
nosy_names = ['ezio.melotti', 'mrabarnett', 'bayat']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue41764'
versions = ['Python 3.8']

@bayat
Copy link
Mannequin Author

bayat mannequin commented Sep 11, 2020

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)

@bayat bayat mannequin added 3.8 (EOL) end of life topic-regex labels Sep 11, 2020
@mrabarnett
Copy link
Mannequin

mrabarnett mannequin commented Sep 11, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants