http://www.perlmonks.org?node_id=117090

Incognito has asked for the wisdom of the Perl Monks concerning the following question:

When parsing through a properly formatted JavaScript file (containing just functions), we are interested in returning the entire string of a specific function, say foo() in this snippet:
foo (a, b, c) { if (c) { a++; } else { b--; } print "hi"; } fum (d, e, f, g, h) { if (d) { e++; } else { f = g + h; } print "ho"; }
we want to match the entire first function... or actually we just want the ability to write a regex that matches any (not too complex is okay) valid function...