Skip to content

editor.research() assigns empty string to non-participating groups (instead of the preferred None) #324

Description

@alankilborn

Under PS 3.0.16.0 (and 2.0.0.0 as well), consider this script:

# -*- coding: utf-8 -*-
from __future__ import print_function

# see

from Npp import *

def match_found(m): print(m.groups())
matches = []
editor.research(r'test data: (\d+)\.?(\d+)?', match_found)

# test data: 24

Run the script with the script itself as the active tab in Notepad++.

Actual Output:
('24', '')

Preferred output:
('24', None)

Rationale for preferred output, see https://docs.python.org/3/library/re.html#match-objects:~:text=Match.groups(default%3DNone), duplicated here:

image

Note that PS does not support the default argument for m.groups() and I'm not requesting that here (that would be a feature/enhancement request, whereas this current issue is more of a bug/enhancement request).

No activity

Activity on this issue will appear here.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions