Skip to content

re.split doesn't respect MULTILINE #59741

Closed

Description

@dabrahams
mannequin
BPO 15536
Nosy @ezio-melotti, @dabrahams, @serhiy-storchaka
Superseder
  • bpo-15537: MULTILINE confuses re.split
  • 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 2012-08-04.21:07:14.545>
    created_at = <Date 2012-08-02.14:41:18.477>
    labels = ['expert-regex', 'type-bug']
    title = "re.split doesn't respect MULTILINE"
    updated_at = <Date 2012-08-04.21:07:14.545>
    user = 'https://github.com/dabrahams'

    bugs.python.org fields:

    activity = <Date 2012-08-04.21:07:14.545>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-08-04.21:07:14.545>
    closer = 'r.david.murray'
    components = ['Regular Expressions']
    creation = <Date 2012-08-02.14:41:18.477>
    creator = 'dabrahams'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 15536
    keywords = []
    message_count = 2.0
    messages = ['167224', '167241']
    nosy_count = 4.0
    nosy_names = ['ezio.melotti', 'mrabarnett', 'dabrahams', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '15537'
    type = 'behavior'
    url = 'https://bugs.python.org/issue15536'
    versions = ['Python 2.7']

    Activity

    1. dabrahams commented on Aug 2, 2012

      dabrahamsmannequin
      MannequinAuthor

      This session demonstrates. See especially the very last expression evaluated

      >>> s='''this is the end
      s='''this is the end
      ... your only friend
      your only friend
      ... the end'''
      the end'''
      >>> re.split('^', s, re.MULTILINE)
      re.split('^', s, re.MULTILINE)
      ['this is the end\nyour only friend\nthe end']
      >>> re.split('t', s, re.MULTILINE)
      re.split('t', s, re.MULTILINE)
      ['', 'his is ', 'he end\nyour only friend\n', 'he end']
      >>> re.split('\n', s, re.MULTILINE)
      re.split('\n', s, re.MULTILINE)
      ['this is the end', 'your only friend', 'the end']
      >>> re.split('(?<=\n)', s, re.MULTILINE)
      re.split('(?<=\n)', s, re.MULTILINE)
      ['this is the end\nyour only friend\nthe end']
      >>> re.split('^y', s, re.MULTILINE)
      re.split('^y', s, re.MULTILINE)
      ['this is the end\nyour only friend\nthe end']
      >>> re.split('$', s, re.MULTILINE)
      re.split('$', s, re.MULTILINE)
      ['this is the end\nyour only friend\nthe end']
      >>> re.split('$\n', s, re.MULTILINE)
      re.split('$\n', s, re.MULTILINE)
      ['this is the end\nyour only friend\nthe end']
      >>> re.split('\n', s, re.MULTILINE)
      re.split('\n', s, re.MULTILINE)
      ['this is the end', 'your only friend', 'the end']
      >>> re.split('^t', s, re.MULTILINE)
      re.split('^t', s, re.MULTILINE)
      ['', 'his is the end\nyour only friend\nthe end']
      >>> re.split('^t', s)
      re.split('^t', s)
      ['', 'his is the end\nyour only friend\nthe end']
      >>>
    2. serhiy-storchaka commented on Aug 2, 2012

      @serhiy-storchaka
      Member

      Same as for bpo-15537.

    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

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions