Partial string matching in R -
this question has answer here: regular expression in base r regex identify email address 2 answers i trying remove 'bad' email addresses csv. have column of emails "abd@no.com," "123@none.com," "@," or "a". there wide range of email formats want try find , remove them all. my inital idea strictly @ end of email string - "@..." part. @ length of character, if email of length 1 or 2 not valid. if have list of bad emails, want generate new list of emails bad ones replaced na. below code have far not work , looks exact matches on pattern, not end of string. email_clean <- function(email, invalid = na) { email <- trimws(email) # remove whitespace email[nchar(email) %in% c(1,2)] <- invalid bad_email <- c("\\@no.com", "\\@none....