Skip to content

Instantly share code, notes, and snippets.

@umuro
Created August 29, 2012 12:50
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 umuro/3512031 to your computer and use it in GitHub Desktop.
Save umuro/3512031 to your computer and use it in GitHub Desktop.
Match a ruby metdhod using regex. To use Thor scripts to replace method definitions in existing source code.
#Match a ruby metdhod using regex. To use Thor scripts to replace method definitions in existing source code.
# github: umuro, Umur Ozkul
def match_mtd(mtd)
/^\s*def (#{mtd})\s+((?!end).)*\s+end\s*$/m
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment