Skip to content

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
@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Apr 9, 2025
@StephanTLavavej StephanTLavavej self-assigned this Apr 9, 2025
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej
Copy link
Member

Resolved adjacent-add conflict in VSO_0000000_regex_use.

@StephanTLavavej StephanTLavavej merged commit b69d5f5 into microsoft:main Apr 10, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews Apr 10, 2025
@StephanTLavavej
Copy link
Member

🐝 🪲 🐞

@muellerj2 muellerj2 deleted the regex-fix-word-bounds-on-empty-string branch April 13, 2025 13:49
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
Archived in project
Development

Successfully merging this pull request may close these issues.

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