-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat: Added escape_regex
operation to the str
namespace and as a global function
#19257
Conversation
@orlp Just to be sure - The code: import polars as pl
df = pl.DataFrame({"text": ["abc", "def", None, "abc(\\w+)"]})
df.with_columns(escaped=pl.escape_regex('text')) Should escape the Besides, I need to:
|
@barak1412 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19257 +/- ##
==========================================
- Coverage 80.21% 80.21% -0.01%
==========================================
Files 1523 1526 +3
Lines 210096 210160 +64
Branches 2432 2434 +2
==========================================
+ Hits 168526 168575 +49
- Misses 41014 41029 +15
Partials 556 556 ☔ View full report in Codecov by Sentry. |
use regex::escape; | ||
|
||
#[inline] | ||
pub fn escape_regex_str(s: &str) -> String { |
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.
Added this function so pl.escape_regex
and str.escape_regex
will be coupled by same implementation.
@orlp I will be glad if you can look, thanks. |
b3a078a
to
040d2c7
Compare
@orlp Should be the right fix now, thanks. |
Looks great @barak1412, we only miss docs entries in the python reference guide. Then it is good to go. |
@ritchie46 Sure, added to the docs. I hope I changed the right places, first time I am touching the docs. Edit: |
…e_regex_escape
…e_regex_escape
…e_regex_escape
…e_regex_escape
…e_regex_escape # Conflicts: # py-polars/tests/unit/operations/namespaces/string/test_string.py
Thanks @barak1412 |
Fixes #19207.