Skip to content

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

Closed

Description

@bayat
mannequin
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']

Activity

  1. bayat commented on Sep 11, 2020

    bayatmannequin
    MannequinAuthor

    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)

  2. mrabarnett commented on Sep 11, 2020

    mrabarnettmannequin
    Mannequin

    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.

  3. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions