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

<regex>: Fix word bounds \b and \B when applied to the empty string #5375

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

muellerj2
Copy link
Contributor

Fixes #5371.

The ECMAScript standard effectively states that \b matches a position i in the string iff IsWordChar(i-1) xor IsWordChar(i) is true. It also defines that for positions i = -1 and i = length(input), IsWordChar(i) always returns false. Thus, \b does not match anything in the empty string.

Since \b does not match the empty string, the flags match_not_bow and match_not_eow don't matter in this case.

@muellerj2 muellerj2 requested a review from a team as a code owner March 28, 2025 17:31
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Mar 28, 2025
@StephanTLavavej StephanTLavavej added bug Something isn't working regex meow is a substring of homeowner labels Mar 29, 2025
@StephanTLavavej StephanTLavavej self-assigned this Mar 29, 2025
@StephanTLavavej
Copy link
Member

Thanks for the fix, test coverage, and clear writeup with citations! I pushed a trivial change to use raw string literals.

@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews Apr 1, 2025
@StephanTLavavej StephanTLavavej removed their assignment Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regex meow is a substring of homeowner
Projects
Status: Ready To Merge
Development

Successfully merging this pull request may close these issues.

<regex>: \b and \B are backwards on empty strings
2 participants