Skip to content

[10.0] Fix Regex.Replace to replace all matches - #4041

Merged
roji merged 1 commit into
hotfix/10.0.4from
roji-regex-replace-10-backport
Oct 19, 2026
Merged

roji merged 1 commit into
hotfix/10.0.4from
roji-regex-replace-10-backport

Conversation

@roji

@roji roji commented Oct 19, 2026

Copy link
Copy Markdown
Member

Backport of #4040 for 10.0, cherry-picked from d747336 without changes.

.NET's Regex.Replace replaces all matches, but the PostgreSQL translation omitted the g flag and replaced only the first. Always append g in TranslateReplace and strengthen the existing replacement tests with multi-match patterns. Shared option translation and Regex.Count are unchanged.

Fixes #4035.

Validation: all 61 regex functional cases passed on .NET 10 with:

dotnet test test/EFCore.PG.FunctionalTests/EFCore.PG.FunctionalTests.csproj --filter 'FullyQualifiedName~NorthwindFunctionsQueryNpgsqlTest.Regex_' --verbosity minimal

Always include the global flag in regexp_replace and exercise multiple matches in existing replacement tests.

(cherry picked from commit d747336)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: be8b4566-8a11-49cd-ad31-b208d3b0e2f7
@roji
roji merged commit 2656d4d into hotfix/10.0.4 Oct 19, 2026
11 checks passed
@roji
roji deleted the roji-regex-replace-10-backport branch October 19, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regex.Replace is translated to regexp_replace without the g flag — only the first match is replaced

1 participant