I have searched and tried methods mentioned in many questions but all methods are taking in consideration only simple use cases. My question is to remove console.log('some data')
for all below cases.
I need a bash script regex to remove below console.log()
and keep the rest of the content intact.
console.log('Some text', variable);
console.log('some text with (a) bracket');
function myfuncton(console.log('some text with covering bracket'));
to function myfuncton();
Note: In the last example, all the content is in single line without any spaces.
I am trying with below regex but it removes all the brackets preceding closing bracket of console.log
. I know the reason but couldn't figure out the regex.
SEARCH_STRING="(\/\/)*console.(log|info|warn)\((.*)\)?"
Do I need to use some other method or it can be done using regex.