I have this function that works like this
Add(1,2);
Add(3,4);
And need to replace with this
Add({num1 : 1, num2 : 2});
Add({num1 : 3, num2 : 4});
This happens in hundreds of places across multiple files so I want to write a script that can do this for me.
Using regex I can find the places where this happens
/Add\(.*\);/
But I'm not sure how to replace the inside of the function call with what I need.
I'm not sure also what the best langauge to use to write the script. I was going to use JavasScript to write it in node but would use Bash with sed if there is an easy solution there.
undefined
and then extract the values from the object provided as first parameter. Most other languages understand default values or proper method overloading. – Till Helge Jul 14 '16 at 10:58Add(1,2,3,4,5);
? – Wiktor Stribiżew Jul 14 '16 at 11:24numberXXX
and with any number of numeric arguments inside theAdd(...)
. – Wiktor Stribiżew Jul 14 '16 at 12:51