Skip to content

why is Python's behavior with empty matches inconsistent with the regex crate's handling of empty matches? #1164

Answered by BurntSushi
rootCircle asked this question in Q&A
Discussion options

You must be logged in to vote

Note that the pattern in your prose does not match the pattern in your programs. This was confusing to me. I've edited your prose to match your code. I've also converted this to a discussion because this isn't a bug, but is a good question.

But no, this is correct behavior. If anything, it's Python's behavior that is somewhat confounding here, because Python's behavior implies it is using an approach that reports overlapping matches. Despite the fact that Python's documentation for re.sub (and re.findall and re.finditer) claims that it reports non-overlapping matches. More generally, there is no specific goal for this crate to match the behavior of any other regex engine. So the existence…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rootCircle
Comment options

Answer selected by BurntSushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1163 on February 13, 2024 13:19.