Skip to content

Instantly share code, notes, and snippets.

@stevenworthington
Created July 11, 2013 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenworthington/5978612 to your computer and use it in GitHub Desktop.
Save stevenworthington/5978612 to your computer and use it in GitHub Desktop.
# list with character vectors
text <- list(a = "all day I play @sworth with R",
b = "all night I play @sworth with R")
# extract letters after "@" in a single character vector
sub("^.*@(\\w+).*", "\\1", text$a)
# extract letters after "@" in a list of character vectors
gsub("^.*@(\\w+).*", "\\1", text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment