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

All regular expression match groups are the empty string #79834

Closed
adiba mannequin opened this issue Jan 3, 2019 · 2 comments
Closed

All regular expression match groups are the empty string #79834

adiba mannequin opened this issue Jan 3, 2019 · 2 comments
Labels
3.7 (EOL) end of life topic-regex type-bug An unexpected behavior, bug, or error

Comments

@adiba
Copy link
Mannequin

adiba mannequin commented Jan 3, 2019

BPO 35653

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 2019-01-04.01:13:35.866>
created_at = <Date 2019-01-03.21:29:10.584>
labels = ['expert-regex', 'invalid', 'type-bug', '3.7']
title = 'All regular expression match groups are the empty string'
updated_at = <Date 2019-01-05.11:05:10.761>
user = 'https://github.com/adiba'

bugs.python.org fields:

activity = <Date 2019-01-05.11:05:10.761>
actor = 'adiba'
assignee = 'none'
closed = True
closed_date = <Date 2019-01-04.01:13:35.866>
closer = 'mrabarnett'
components = ['Regular Expressions']
creation = <Date 2019-01-03.21:29:10.584>
creator = 'adiba'
dependencies = []
files = []
hgrepos = []
issue_num = 35653
keywords = []
message_count = 2.0
messages = ['332948', '332956']
nosy_count = 0.0
nosy_names = []
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue35653'
versions = ['Python 3.7']

@adiba
Copy link
Mannequin Author

adiba mannequin commented Jan 3, 2019

This is the regular expression: ^(?:(\d*)(\D*))*$
This is the test string: 42AZ
This is the expectation for the match groups: ('42', 'AZ')
This is the actual return value: ('', '')

https://gist.github.com/adiba/791ba943a1102994d43171dc98aaecd0

@adiba adiba mannequin added 3.7 (EOL) end of life topic-regex type-bug An unexpected behavior, bug, or error labels Jan 3, 2019
@mrabarnett
Copy link
Mannequin

mrabarnett mannequin commented Jan 4, 2019

Look at the spans of the groups:

>>> import re
>>> re.search(r'^(?:(\d*)(\D*))*$', "42AZ").span(1)
(4, 4)
>>> re.search(r'^(?:(\d*)(\D*))*$', "42AZ").span(2)
(4, 4)

They're telling you that the groups are matching twice (because of the outer *). The first time, they match ('42', 'AZ'); the second time, they match ('', '') at the end of the string.

Not a bug.

@mrabarnett mrabarnett mannequin closed this as completed Jan 4, 2019
@mrabarnett mrabarnett mannequin added the invalid label Jan 4, 2019
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life topic-regex type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

0 participants