I try to use stringr
package to extract part of a string, which is between two particular patterns.
For example, I have:
my.string <- "nanaqwertybaba"
left.border <- "nana"
right.border <- "baba"
and by the use of str_extract(string, pattern)
function (where pattern is defined by a POSIX regular expression) I would like to receive:
"qwerty"
Solutions from Google did not work.
left.border
andright.border
, 2. match up to first occurence ofright.border
and now I have:rx <- regexpr(paste0("(?<=", left.border, ")(.*?)+(?=", right.border, ")"), text = my.string, perl = TRUE)
. Big thank you to you! – Fredia