Refactoring with regular expressions
I’m re-learning JavaScript, and I noticed I was refactoring functions a lot on some old code. I’m putting some useful stuff here for reference:
aFunc(blah) → this.aFunc = function(blah)
Find: function (\w+)(
Replace with: this.\1 = function(
To go the other way:
Find: \t(\w+)\s=\sfunction(
Replace with: \tfunction \1(
Change aFunc(blah) to SOME.qualifier.aFunc(blah)
**Find: **\t(\w+()
**Replace with: **\tSOME.qualifier.\1