Skip to contents

Keep only a type of characters in a string.

Usage

str_keep(string, keep = c("text", "numbers", "special"))

Arguments

string

A character vector

keep

A character single value (default = 'text'), that will be the type of character to keep

Value

A character vector.

Details

The argument 'keep' can be one of: 'text', 'number', 'special'.

Examples


string <- "1ABCF45Z89$$%#"

str_keep(string,keep = "text")
#> [1] "ABCFZ"

str_keep(string,keep = "numbers")
#> [1] 14589

str_keep(string,keep = "special")
#> [1] "$$%#"