Learn R Programming

RVerbalExpressions (version 0.0.0.9000)

not: Ensure that the parameter does not follow.

Description

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".

Usage

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

Run this code
# NOT RUN {
not(value = "FEB-28")

# construct expression
x <- start_of_line() %>%
  find('FEB-29') %>%
  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))

# another example
find(value = "q") %>%
  not("u") %>%
  grepl(x = c("qu", "qa", "qq", "q", "q u"), perl = TRUE)

# }

Run the code above in your browser using DataLab