Regular Expressions 101

Community Patterns

extract JavaScript function name

1

Regular Expression
ECMAScript (JavaScript)

/
^\s*function\s+(\w+)\s*\(
/

Description

Extracts the name of the outer function. Useful to get the name of a function reference using fn.toString().

Submitted by Jack A. - 10 years ago