This expression uses a negative lookahead to ensure the value given does not follow the previous verbal expression, perl = TRUE is required. For example, if you were to look for the letter q but not the letter u you might translate this to, "find the letter q everytime the letter u does not come after it".

rx_not(.data = NULL, value)

Arguments

.data

Expression to append, typically pulled from the pipe %>%

value

Value to ensure absence of

References

Negative lookahead: https://www.regular-expressions.info/lookaround.html

Examples

rx_not(value = "FEB-28")
#> [1] "(?!FEB-28)"
# construct expression x <- rx() %>% rx_start_of_line() %>% rx_find('FEB-29') %>% rx_not("FEB-28") # create a string string <- c("FEB-29-2017", "FEB-28-2017") # extract matches, perl = TRUE is required for negative lookahead regmatches(string, regexpr(x, string, perl = TRUE))
#> [1] "FEB-29"
# another example rx() %>% rx_find("q") %>% rx_not("u") %>% grepl(x = c("qu", "qa", "qq", "q", "q u"), perl = TRUE)
#> [1] FALSE TRUE TRUE TRUE TRUE