Skip to content

re.split, re.sub and re.subn should support flags #47732

Closed

Description

@benoit
mannequin
BPO 3482
Nosy @rhettinger, @pitrou, @bitdancer

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 2010-10-17.03:17:26.107>
created_at = <Date 2008-08-01.07:20:21.211>
labels = ['expert-regex', 'easy', 'type-feature']
title = 're.split, re.sub and re.subn should support flags'
updated_at = <Date 2010-10-17.03:17:26.047>
user = 'https://bugs.python.org/benoit'

bugs.python.org fields:

activity = <Date 2010-10-17.03:17:26.047>
actor = 'r.david.murray'
assignee = 'none'
closed = True
closed_date = <Date 2010-10-17.03:17:26.107>
closer = 'r.david.murray'
components = ['Regular Expressions']
creation = <Date 2008-08-01.07:20:21.211>
creator = 'benoit'
dependencies = []
files = []
hgrepos = []
issue_num = 3482
keywords = ['easy']
message_count = 5.0
messages = ['70543', '71166', '113637', '118611', '118912']
nosy_count = 6.0
nosy_names = ['rhettinger', 'pitrou', 'timehorse', 'benoit', 'r.david.murray', 'mjkeeler7']
pr_nums = []
priority = 'normal'
resolution = 'accepted'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue3482'
versions = ['Python 3.2']

Activity

  1. benoit commented on Aug 1, 2008

    benoitmannequin
    MannequinAuthor

    Given that the search operations support flags, it seems natural for a
    developer that the other functions in the module support flags as well.
    So when running "re.split(pattern, string, re.I)", the split() command
    seems to not work and don't return a message error (I understand that
    're.I' is understood as 'maxsplit=0'.)

    This is confusing and I think that it should be changed so that all
    functions in the module are consistent.

  2. pitrou commented on Aug 15, 2008

    @pitrou
    Member

    Please note that the flags can be inlined in the pattern instead. That
    is, you can begin the pattern with "(?i)" instead of passing re.I in the
    flags parameter.

  3. added
    type-featureA feature request or enhancement
    and removed
    type-bugAn unexpected behavior, bug, or error
    on Aug 15, 2008
  4. rhettinger commented on Aug 11, 2010

    @rhettinger
    Contributor

    This request seems reasonable.

  5. mjkeeler7 commented on Oct 14, 2010

    mjkeeler7mannequin
    Mannequin

    Python 2.7 docs say this was added in 2.7.3.1
    Python 3.1 docs say this was added in 3.1

    The problem with calling 're.split(pattern, string, re.I)' is that you are using positional arguments only. If you were to do 're.split(pattern, string, flags=re.I)', that should produce the desired result.

  6. bitdancer commented on Oct 17, 2010

    @bitdancer
    Member

    For reference, the py3k rev was r70091.

  7. 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