# NOT RUN {
x <- c(
"fred is [email protected] and joe is [email protected] - but @this is a",
"twitter handle for [email protected] or [email protected]/[email protected]",
"hello world",
NA
)
replace_email(x)
replace_email(x, replacement = '<<EMAIL>>')
replace_email(x, replacement = '<a href="mailto:$1" target="_blank">$1</a>')
## Replacement with a function
replace_email(x,
replacement = function(x){
sprintf('<a href="mailto:%s" target="_blank">%s</a>', x, x)
}
)
replace_email(x,
replacement = function(x){
gsub('@.+$', ' {{at domain}}', x)
}
)
# }
Run the code above in your browser using DataLab