Skip to content
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(rust,python): handle edge-case with string-literal replacement when the replace value looks like a capture group #6765

Merged

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Feb 9, 2023

Closes #6755.

Addresses edge-case with literal string replacement when using the regex engine. If the replacement pattern looks like (or contains) a capture group string you could get some unexpected/failed substitutions...

Example

import polars as pl
s = pl.Series( "srs", ["."] )
s.str.replace_all( ".", "$0", literal=True )[0]

Before: '.' (applied capture group, despite "literal=True")
After: '$0' (capture group syntax ignored, literal properly replaced)

Also

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Feb 9, 2023
@alexander-beedie alexander-beedie force-pushed the fix-regex-literal-replace branch 2 times, most recently from 57599bc to 677edcb Compare February 10, 2023 05:20
…en the replace value looks like a regex capture group
@ritchie46 ritchie46 merged commit 4607eb6 into pola-rs:master Feb 10, 2023
@alexander-beedie alexander-beedie deleted the fix-regex-literal-replace branch February 10, 2023 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
2 participants