-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix: Capture groups should be ignored in replace_all when literal=True #19366
Conversation
reg.replace_all(s, val) | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still a bit new at Rust. I ended up putting an if
in the lambda when what I really wanted was to create the lambda I need once based on the literal
. This is probably slightly slower, but I doubt it matters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lambda's will be different. So you must either put them behind an indirection or call iter_and_replace
in the branches.
But here it won't really matter indeed.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19366 +/- ##
==========================================
+ Coverage 80.02% 80.20% +0.17%
==========================================
Files 1528 1523 -5
Lines 209871 209859 -12
Branches 2419 2434 +15
==========================================
+ Hits 167954 168314 +360
+ Misses 41366 40990 -376
- Partials 551 555 +4 ☔ View full report in Codecov by Sentry. |
Fixes #18238.
From the docs, (https://docs.pola.rs/api/python/stable/reference/expressions/api/polars.Expr.str.replace_all.html#polars-expr-str-replace-all), when literal=True, then capture groups should be ignored. As the docs say:
Fix the Rust logic which did not apply this logic for multi-row replacement.