I was wanting to organize all my javascript functions to put them in alphabetical order a month ago or so and was playing with a regular expression today that made me think of that again. I only want to match the outer functions to avoid nested functions getting moved and almost had it I think, but there is something I am missing.
I used bobble bubble's answer on this page as a starting point. Regular Expression to match outer brackets
function\s.*\(.*\).*\{(?>[^.*\n*]+|(?R))*\}
This will match all function definitions and capture the arguments up to the first curly brace. For some reason I can't get it to match the newlines pattern [^.*\n*]+
while it is part of the expression, but when it is all by itself it matches just fine.
I was using Sublime text editor as my tool to search, but it would end up in a JS file probably as an easy way to manipulate the code.