PCRE SKIP/FAIL (\\s*), >, (\\s*). (*SKIP) . (*FAIL) (* SKIP), (|\\s+) ((*FAIL)) ("")
gsub("\\s*\\>\\s*(*SKIP)(*FAIL)|\\s+", "", str1, perl = TRUE)
#[1] "foo > bar > foobar > foo > test > testthis"
- . regex lookbehind ((?<=\\w)) ((?=\\w|\\$))
gsub("(?<=\\w)\\s(?=\\w|\\$)", "", str1, perl = TRUE)
#[1] "foo > bar > foobar > foo > test > testthis"
,
gsub("(\\w)\\s(\\w)", "\\1\\2", str1)
#[1] "foo > bar > foobar > foo > test > testthis"
str1 <- "foo > bar > foo bar > foo > test > test this"