ianmcook commented on a change in pull request #9878:
URL: https://github.com/apache/arrow/pull/9878#discussion_r607290585
##########
File path: r/R/dplyr.R
##########
@@ -434,6 +438,77 @@ build_function_list <- function(FUN) {
)
}
+arrow_r_string_replace_function <- function(FUN, max_replacements) {
+ function(pattern, replacement, x, ignore.case = FALSE, fixed = FALSE) {
+ if (ignore.case) {
+ if (fixed) {
+ pattern <- gsub("\\E", "\\e", pattern, fixed = TRUE)
+ pattern <- paste0("(?i)\\Q", pattern, "\\E")
+ replacement <- gsub("\\", "\\\\", replacement, fixed = TRUE)
+ } else {
+ pattern <- paste0("(?i)", pattern)
+ }
+ }
Review comment:
@maartenbreddels since ARROW-10306 did not directly support
string-insensitive fixed string replacement (non-regex), this is the workaround
we used to support this in the R bindings. Feedback welcome, and thanks for
your work on the underlying C++ code!
##########
File path: r/R/dplyr.R
##########
@@ -434,6 +438,77 @@ build_function_list <- function(FUN) {
)
}
+arrow_r_string_replace_function <- function(FUN, max_replacements) {
+ function(pattern, replacement, x, ignore.case = FALSE, fixed = FALSE) {
+ if (ignore.case) {
+ if (fixed) {
+ pattern <- gsub("\\E", "\\e", pattern, fixed = TRUE)
+ pattern <- paste0("(?i)\\Q", pattern, "\\E")
+ replacement <- gsub("\\", "\\\\", replacement, fixed = TRUE)
+ } else {
+ pattern <- paste0("(?i)", pattern)
+ }
+ }
Review comment:
@maartenbreddels since ARROW-10306 did not directly support
case-insensitive fixed string replacement (non-regex), this is the workaround
we used to support this in the R bindings. Feedback welcome, and thanks for
your work on the underlying C++ code!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]