rx_not: Ensure that the parameter does not follow.

Description Usage Arguments References Examples

View source: R/rules.R

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
rx_not(value = "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))

# another example
rx() %>%
  rx_find("q") %>%
  rx_not("u") %>%
  grepl(x = c("qu", "qa", "qq", "q", "q u"), perl = TRUE)

RVerbalExpressions documentation built on Nov. 6, 2019, 5:08 p.m.