Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- v1 <- c("I will try to fix you usman@usman.com", "I will try to fix you", "Zombies Zombies xyz@ymail.com")
- v2 < c("ABC", "XYZ", "Oh Game")
- dx <- data.frame(v1, v2)
- ABC usman@usman.com
- XYZ NA
- Oh Game xyz@ymail.com
- dx$emails <- sapply(dx$v1, function(x) {
- email <- regmatches(x, regexpr("[[:alnum:]]+\@[[:alpha:]]+\.com", x))
- (result <- ifelse(identical(email, character(0)), NA, email))
- })
Add Comment
Please, Sign In to add comment