GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — re.sub() does not work correctly on '.' pattern and \n · Issue #75110 · python/cpython

re.sub() does not work correctly on '.' pattern and \n #75110

New issue
Copy link
New issue
Copy link
Closed
Closed
re.sub() does not work correctly on '.' pattern and \n#75110
Copy link
Labels
topic-regextype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

mrh1997
mannequin
opened on Jul 13, 2017
Issue body actions
BPO 30927
Nosy @ezio-melotti, @mrh1997

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 2017-07-13.23:58:25.716>
created_at = <Date 2017-07-13.21:27:56.387>
labels = ['expert-regex', 'type-bug', 'invalid']
title = "re.sub() does not work correctly on '.' pattern and \\n"
updated_at = <Date 2017-07-13.23:58:25.715>
user = 'https://github.com/mrh1997'

bugs.python.org fields:

activity = <Date 2017-07-13.23:58:25.715>
actor = 'mrabarnett'
assignee = 'none'
closed = True
closed_date = <Date 2017-07-13.23:58:25.716>
closer = 'mrabarnett'
components = ['Regular Expressions']
creation = <Date 2017-07-13.21:27:56.387>
creator = 'mrh1997'
dependencies = []
files = []
hgrepos = []
issue_num = 30927
keywords = []
message_count = 2.0
messages = ['298316', '298323']
nosy_count = 3.0
nosy_names = ['ezio.melotti', 'mrabarnett', 'mrh1997']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue30927'
versions = ['Python 3.6']

Activity

  1. mrh1997 commented on Jul 13, 2017

    @mrh1997
    mrh1997mannequin
    on Jul 13, 2017
    MannequinAuthor
    More actions

    When running the command

        re.sub(r'X.', '+', '-X\n-', re.DOTALL)

    you get '-X\n-' instead of '-+-'.

    Curiously findall works correctly:

    re.findall(r'X.', '-X\n-', re.DOTALL) => ['X\n']
    
  2. mrh1997
    added
    topic-regex
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jul 13, 2017
  3. mrabarnett commented on Jul 13, 2017

    @mrabarnett
    mrabarnettmannequin
    on Jul 13, 2017
    Mannequin
    More actions

    The 4th parameter is the count, not the flags:

    sub(pattern, repl, string, count=0, flags=0)
    >>> re.sub(r'X.', '+', '-X\n-', flags=re.DOTALL)
    '-+-'
  4. mrabarnett
    closed this as completedon Jul 13, 2017
  5. mrabarnett
    added
    invalid
    on Jul 13, 2017
  6. ezio-melotti
    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

    Labels

    topic-regextype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.