Regular Expressions 101

Community Patterns

1...45678...901

Community Library Entry

4

Regular Expression
ECMAScript (JavaScript)

/
function\s*([A-z0-9]+)?\s*\((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*\)\s*\{(?:[^}{]+|\{(?:[^}{]+|\{[^}{]*\})*\})*\}
/
g

Description

matches both function declarations and expressions in javascript. ex. function name () {...} || function () {}

Submitted by Ja Superior - 9 years ago