longstrings <- c("analysis.\\\",\\\"title\\\":\\\"RSS CCMP V3.1 6-hourly surface winds (Level 4)\\\",\\\"coordinates\\\":\\\"latitude longitude t",
"dsaoijdoijdd09d9de9e9e9e00\"RSS CCMPbalsljdojasdoiewwiow8us98hasdhasd")
findregions <- function(x, pattern, window = 10) {
index <- gregexpr(pattern, x)
outlist <- vector("list", length(index))
for (i in seq_along(index)) {
outlist[[i]] <- character(length(index[[i]]))
for (j in seq_along(index[[i]])) {
outlist[[i]][j] <- substr(x[i], index[[i]][j] - window, index[[i]][j] + window)
}
}
outlist
}
findregions(longstrings, "CCMP")
[[1]]
[1] "e\\\":\\\"RSS CCMP V3.1 6"
[[2]]
[1] "e9e00\"RSS CCMPbalsljd"
Created
May 8, 2025 01:50
-
-
Save mdsumner/8b00dcde61d82f869cf8adacd88d717a to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment