Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alankilborn opened this issue Jan 24, 2024 · 0 comments

Comments

@alankilborn
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant