Skip to content

Conversation

muellerj2
Copy link
Contributor

@muellerj2 muellerj2 commented Dec 6, 2024

According to Sections 9.3.6 and 9.5.1 of the POSIX standard, a backreference is a backslash followed by a single digit, so \1 to \9. Thus, \(a\)\10 is a valid basic regular expression matching the string aa0, because \10 is a backreference to capture group 1 (\(a\)) plus the digit 0. However, the regex parser currently rejects this regular expression because it interprets \10 as a backreference to capture group 10.

After this PR, the parser only reads a single digit in basic regular expression (and grep) mode, so \10 is parsed correctly as a backreference to capture group 1 plus digit 0.

@muellerj2 muellerj2 requested a review from a team as a code owner December 6, 2024 15:03
@CaseyCarter CaseyCarter added the bug Something isn't working label Dec 7, 2024
@StephanTLavavej StephanTLavavej self-assigned this Dec 7, 2024
@StephanTLavavej StephanTLavavej removed their assignment Dec 9, 2024
@StephanTLavavej StephanTLavavej self-assigned this Dec 10, 2024
@StephanTLavavej StephanTLavavej added the regex meow is a substring of homeowner label Jan 8, 2025
@StephanTLavavej
Copy link
Member

Excellent, thank you! 💚 I pushed small stylistic nitpicks.

@StephanTLavavej
Copy link
Member

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

@StephanTLavavej StephanTLavavej merged commit bbd15ba into microsoft:main Jan 14, 2025
39 checks passed
@StephanTLavavej
Copy link
Member

Thanks for properly implementing this grammar! 1️⃣ 9️⃣ 🐱

@muellerj2 muellerj2 deleted the fix-basic-backreferences branch January 14, 2025 20:21
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.

3 participants