Created
July 24, 2013 18:11
-
-
Save lauratboyer/6073009 to your computer and use it in GitHub Desktop.
This function allows you to extract the part of the string that matches the regular expression given as input. For instance, if you have species names and want to extract the gender only, you would type: getmatch("Echinometra mathaei", "^\\w+") # Echinometra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getmatch <<- function(x,str2match,...) { | |
unlist(regmatches(x,regexpr(str2match,x,...))) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment