jorisvandenbossche commented on PR #39264:
URL: https://github.com/apache/arrow/pull/39264#issuecomment-1881433529

   And then R seems to have the same behaviour as Python (`sub` only replaces 
the first occurrence):
   
   ```R
   > sub("test", "t", "z")
   [1] "z"
   > sub("t", "z", "test")
   [1] "zest"
   > sub("", "z", "test")
   [1] "ztest"
   > gsub("t", "z", "test")
   [1] "zesz"
   > gsub("", "z", "test")
   [1] "ztzezsztz"
   ```
   
   And the tidyverse version of this function raises an error:
   
   ```R
   > library(stringr)
   > str_replace("test", "t", "z")
   [1] "zest"
   > str_replace("test", "", "z")
   Error in `str_replace()`:
   ! `pattern` can't be the empty string (`""`).
   ```
   
   So we already have examples of three different behaviours .. (replace 
(insert) every other string, replace nothing, error)


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to