# match whitespace, default
rx_whitespace()
# dont match whitespace
rx_whitespace(inverse = TRUE)
# create an expression
x <- rx_whitespace()
# create input
string <- "1 apple"
# extract match
regmatches(string, regexpr(x, string))
# extract no whitespace by inverting behavior
y <- rx_whitespace(inverse = TRUE)
regmatches(string, gregexpr(y, string))
Run the code above in your browser using DataLab