Matches punctuation characters only: ! \" # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~.

rx_punctuation(.data = NULL, inverse = FALSE)

Arguments

.data

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

inverse

Invert match behavior, defaults to FALSE (match punctuation). Use TRUE to not match punctuation.

Examples

rx_punctuation()
#> [1] "[[:punct:]]"
rx_punctuation(inverse = TRUE)
#> [1] "[^[:punct:]]"
# create an expression x <- rx_punctuation() # create input string <- 'Apple 1!' # extract match regmatches(string, gregexpr(x, string))
#> [[1]] #> [1] "!" #>
# dont extract punctuation y <- rx_punctuation(inverse = TRUE) regmatches(string, gregexpr(y, string))
#> [[1]] #> [1] "A" "p" "p" "l" "e" " " "1" #>