Last active
May 22, 2018 11:35
-
-
Save sagirk/9ae78b3bd8aebec5d27182b29aeed8a6 to your computer and use it in GitHub Desktop.
Regular expression to search for functions (regular and fat arrow) in JavaScript code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Match for patterns: `function (...) {...}` and `(...) => {...}` | |
* (`...` could be zero or more words, digits, spaces, underscores, commas) | |
*/ | |
/function\s*\(([\w\d\s_,]*)\)\s*\{([^}]*)\}|\(([\w\d\s_,]*)\)\s*=>\s*\{([^}]*)\}/gi | |
/** | |
* Match for patterns: `function (...)` and `(...) =>` | |
* (`...` could be zero or more words, digits, spaces, underscores, commas) | |
*/ | |
/function\s*\(([\w\d\s_,]*)\)|\(([\w\d\s_,]*)\)\s*=>/gi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment