trinker / qdapRegex

qdapRegex is a collection of regular expression tools associated with the qdap package that may be useful outside of the context of discourse analysis.
50 stars 4 forks source link

rm_between doesn't take a regular ecpression for left/right args: #15

Closed trinker closed 9 years ago

trinker commented 9 years ago
x <-  c("There are 2.3 million species in the world",
    "There are 2.3 billion species in the world")

rm_between(x, left='There', right = '[mb]illion', extract=TRUE, include=T)
trinker commented 9 years ago

The fixed argument has been added.

rm_between and r_between_multiple pick up a fixed argument. Previously, left and right boundaries containing regular expression special characters were fixed by default (escaped). This did not allow for the powerful use of a regular expression for left/right boundaries. The fixed = TRUE behavior is still the default but users can now set fixed = FALSE to work with regular expression boundaries. This new feature was inspired by @Ronak Shah's StackOverflow question: http://stackoverflow.com/q/31623069/1000343

Using qdapRegex version >= 4.1 you can do the following.

x <-  c(
    "There are 2.3 million species in the world",
    "There are 2.3 billion species in the world"
)

rm_between(x, left='There', right = '[mb]illion', fixed = FALSE,
    include=TRUE, extract = TRUE)

## [[1]]
## [1] "There are 2.3 million"
## 
## [[2]]
## [1] "There are 2.3 billion"