library(tidyverse)
# Toy data
df <- tibble(
x = c("123Abcde789",
"46765%-''098",
"565--456A",
"1232133456",
"'''890976")
)
df
#> # A tibble: 5 x 1
#> x
#> <chr>
#> 1 123Abcde789
#> 2 46765%-''098
#> 3 565--456A
#> 4 1232133456
#> 5 '''890976
How do I identify rows that contain special characters other than alphanumeric characters or - ? For example, desired code will identify rows 2 and 5 from df because row 2 contains %'' and row 5 contains '''.
Thanks a lot @FJCC ! Could you please explain the following part? I would like to learn which part is identifying alphanumeric characters and which part is identifying the -. "[^-A-Za-z0-9]"
The first - represents that character in the regular expression. A-Z represents all of the upper case letters, a-z is the lower case letters, and 0-9 is all of the numeric characters.