Skip to content

Instantly share code, notes, and snippets.

@skeggse
Created January 27, 2014 22:41
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 skeggse/8658832 to your computer and use it in GitHub Desktop.
Save skeggse/8658832 to your computer and use it in GitHub Desktop.
A regular expression which finds javascript functions that return their first value. Doesn't handle comments.
function\s*[^\(]*\(\s*([\$a-z][\$a-z0-9]*)\s*\)\s*\{\s*return\s+\1\s*;?\s*\}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment