Test, validate and match regular expressions
This regular expression matches JavaScript function declarations and named function expressions. It captures the optional function name and accurately handles nested parentheses for parameters and nested curly braces for the function body up to two levels deep. It is typically used for syntax highlighting, basic code analysis, or extracting function definitions from JavaScript source code.