17.3 Substitute or remove matching patterns with gsub

From the same vector of email addresses:

  • Remove the “@” symbol and the email provider from each address
gsub(pattern="@[a-z.]+",
        replacement="",
        x=vec_ad)
  • Substitute the “@” symbol with “at
gsub(pattern="@",
        replacement="_at_",
        x=vec_ad)
  • Substitute “es” and “it” by “eu”
gsub(pattern="es$|it$", 
    replacement="eu", 
    x=vec_ad)