Skip to content

Fix Issue 11025 - case-insensitive backreferences in std.regex#11070

Open
niy-ati wants to merge 2 commits into
dlang:masterfrom
niy-ati:fix-11025-regex-backref-casefold
Open

Fix Issue 11025 - case-insensitive backreferences in std.regex#11070
niy-ati wants to merge 2 commits into
dlang:masterfrom
niy-ati:fix-11025-regex-backref-casefold

Conversation

@niy-ati

@niy-ati niy-ati commented Jul 18, 2026

Copy link
Copy Markdown

Summary

  • Under /i, IR.Backref compared captures with ==, so (.)\1 matched BB but not Aa.
  • Compare with simple case folding when RegexOption.casefold is set (backtracking, Thompson, and ctRegex).
  • Add regression vectors for issue 11025.

Fixes #11025

Test plan

  • Added TestVectors for Aa / aA / BB / non-match / multi-char / (?i).
  • CI

Under /i, literals are casefolded at parse time but IR.Backref still
compared codepoints with ==. Use simple case folding when matching
backrefs in the backtracking and Thompson engines (and ctRegex).
@niy-ati
niy-ati requested a review from DmitryOlshansky as a code owner July 18, 2026 15:49
Comment thread std/regex/internal/tests.d Outdated
TestVectors( `[adzУ-Я]{4}`, "DzюЯ", "y", "$&", "DzюЯ", "i"),
TestVectors( `\p{L}\p{Lu}{10}`, "абвгдеЖЗИКЛ", "y", "$&", "абвгдеЖЗИКЛ", "i"),
TestVectors( `(?:Dåb){3}`, "DåbDÅBdÅb", "y", "$&", "DåbDÅBdÅb", "i"),
// Issue 11025: backrefs must casefold under /i

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Issue 11025: backrefs must casefold under /i
// https://github.com/dlang/phobos/issues/11025 backrefs must casefold under /i

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the comment to link the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Std.regex: backreferences do not match text with different casing

3 participants