Closed aedobbyn closed 2 years ago
I wonder if replace_to
& replace_from
in the textclean package (dev version on github) suit your needs?
https://github.com/trinker/textclean/blob/master/R/replace_to.R
It does! Funny enough I just ran into the same use case in a different project and regex puzzled it out. This would have been much simpler! textclean
has so many of the little utility functions always find myself making -- great to have it in one spot.
Just a heads up, the install initially failed with
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace ‘lexicon’ 0.7.4 is being loaded, but >= 1.0.0 is required
until I installed lexicon
from CRAN. If it's useful to you:
devtools::session_info()
#> Session info -------------------------------------------------------------
#> setting value
#> version R version 3.4.4 (2018-03-15)
#> system x86_64, darwin15.6.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> tz America/Chicago
#> date 2018-05-31
#> Packages -----------------------------------------------------------------
#> package * version date source
#> backports 1.1.2 2017-12-13 CRAN (R 3.4.3)
#> base * 3.4.4 2018-03-15 local
#> compiler 3.4.4 2018-03-15 local
#> datasets * 3.4.4 2018-03-15 local
#> devtools 1.13.5 2018-02-18 CRAN (R 3.4.3)
#> digest 0.6.15 2018-01-28 CRAN (R 3.4.3)
#> evaluate 0.10.1 2017-06-24 CRAN (R 3.4.1)
#> graphics * 3.4.4 2018-03-15 local
#> grDevices * 3.4.4 2018-03-15 local
#> htmltools 0.3.6 2017-04-28 CRAN (R 3.4.0)
#> knitr 1.20 2018-02-20 CRAN (R 3.4.3)
#> magrittr 1.5 2014-11-22 CRAN (R 3.4.0)
#> memoise 1.1.0 2017-04-21 CRAN (R 3.4.0)
#> methods * 3.4.4 2018-03-15 local
#> Rcpp 0.12.16 2018-03-13 CRAN (R 3.4.4)
#> rmarkdown 1.9 2018-03-01 CRAN (R 3.4.3)
#> rprojroot 1.3-2 2018-01-03 CRAN (R 3.4.3)
#> stats * 3.4.4 2018-03-15 local
#> stringi 1.1.7 2018-03-12 CRAN (R 3.4.4)
#> stringr 1.3.0 2018-02-19 CRAN (R 3.4.3)
#> tools 3.4.4 2018-03-15 local
#> utils * 3.4.4 2018-03-15 local
#> withr 2.1.2 2018-03-15 CRAN (R 3.4.4)
#> yaml 2.1.18 2018-03-08 CRAN (R 3.4.4)
This is a great package! Forgive me since I'm new to it and there may be a good reason why you check that both
left
andright
markers are supplied.For my particular use case, it's useful to extract everything up to a certain word or everything after it. Is there a reason not to set both
left
andright
arguments toNULL
and allow the users to give one or both?Cheers!