I tried to use the \K
in a separator string definition, but gives an error:
text_to_split = "Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet"
tibble(chuck = text_to_split) %>%
separate_rows(chunk, sep = "amet\K")
#> Error: '\K' is an unrecognized escape in character string starting ""amet\K"
This is what I tried to achieve: regex101: build, test, and debug regex
Previously, I used the lookbehind in my separator string definitions, but the lookbehind is very slow (comparing with the lookahead). Secondly, the lookbehind requires fixed length string definitions (error: 'lookbehind assertion is not fixed length') . Considering these limitations I want to replace the lookbehind in my code. The \K
looked like a promising alternative.
(some details on \K
: Keep The Text Matched So Far out of The Overall Regex Match)