Examples for 'stringr::invert_match'


Switch location of matches to location of non-matches

Aliases: invert_match

Keywords:

### ** Examples

numbers <- "1 and 2 and 4 and 456"
num_loc <- str_locate_all(numbers, "[0-9]+")[[1]]
str_sub(numbers, num_loc[, "start"], num_loc[, "end"])
[1] "1"   "2"   "4"   "456"
text_loc <- invert_match(num_loc)
str_sub(numbers, text_loc[, "start"], text_loc[, "end"])
[1] ""      " and " " and " " and " ""     

[Package stringr version 1.5.1 Index]