Last active
July 3, 2019 19:57
-
-
Save robballou/dd72b6e51a6ebcc4e601a1e3e8c1fe0c to your computer and use it in GitHub Desktop.
JavaScript regex for find/replace
This file contains hidden or 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 function declarations for converting to function expressions | |
const regex = /^(export\s?)?(async\s?)?function ([^(]+)(\([^)]*\))(\s*:[^{]+)? {/ | |
// replace: $1const $3 = $2$4$5 => { | |
// class methods... caution! this also replaces if statements | |
const regex2 = /([^(]+)\((.+)\) {/ | |
// replace $1 = ($2) => { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment