-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
3.14bugs and security fixesbugs and security fixestopic-regextype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
>>> import re
>>> list(re.finditer(r'\b', 'e'))
[<re.Match object; span=(0, 0), match=''>, <re.Match object; span=(1, 1), match=''>]
>>> list(re.finditer(r'\B', 'e'))
[]
>>> list(re.finditer(r'\b', '%'))
[]
>>> list(re.finditer(r'\B', '%'))
[<re.Match object; span=(0, 0), match=''>, <re.Match object; span=(1, 1), match=''>]
>>> list(re.finditer(r'\b', ''))
[]
>>> list(re.finditer(r'\B', ''))
[]
Apparently the empty string neither is nor isn't a word boundary. Is that supposed to happen? \B matches the empty string in every other language I can think of.
Online reproducer: https://godbolt.org/z/8q6fehss7
CPython versions tested on:
3.11, 3.12
Operating systems tested on:
Linux
Linked PRs
- gh-124130: Notes on empty string corner case of category
\B
#124133 - [3.13] gh-124130: Notes on empty string corner case of category
\B
(GH-124133) #124328 - [3.12] gh-124130: Notes on empty string corner case of category
\B
(GH-124133) #124329 - gh-124130: Increase test coverage for \b and \B in regular expressions #124330
- [3.13] gh-124130: Increase test coverage for \b and \B in regular expressions (GH-124330) #124413
- [3.12] gh-124130: Increase test coverage for \b and \B in regular expressions (GH-124330) #124414
- gh-124130: Fix a bug in matching regular expression \B in empty string #127007
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixestopic-regextype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error