Match a whitespace character.
rx_whitespace(.data = NULL, inverse = FALSE)
.data | Expression to append, typically pulled from the pipe |
---|---|
inverse | Invert match behavior, defaults to |
Match a whitespace character (one of space, tab, carriage return, new line, vertical tab and form feed).
carriage return: https://codepoints.net/U+000D
new line: https://codepoints.net/U+000
vertical tab: https://codepoints.net/U+000B
form feed: https://codepoints.net/U+000C
# match whitespace, default rx_whitespace()#> [1] "\\s"# dont match whitespace rx_whitespace(inverse = TRUE)#> [1] "[^ \t\r\n]"# create an expression x <- rx_whitespace() # create input string <- "1 apple" # extract match regmatches(string, regexpr(x, string))#> [1] " "# extract no whitespace by inverting behavior y <- rx_whitespace(inverse = TRUE) regmatches(string, gregexpr(y, string))#> [[1]] #> [1] "1" "a" "p" "p" "l" "e" #>