I’m trying to replace an old function call with an updated function.
I’m looking for something like this:
$myvar = myclass::getmyvar();
However the tabs / spacing can vary wildly due to code formatting. How can I match for any number of tabs or spaces between the $myvar and the = myclass::getmyvar();?
I’ve tried variations of something like this:
$myvar[* \t]=[* ]myclass::getmyvar();
without success.
I’d like to pass it to a statement like the following:
grep -rl '$myvar[* \t]=[* ]myclass::getmyvar();' ./ | xargs sed -i 's/$myvar[* \t]=[* ]myclass::myvar();/$myvar = mynewclass::myvar();/g'
Is that the proper syntax, or should I be using egrep?
I believe your problem lies with the location of your
*and not escaping$,(and). This will yield better results.In addition, you can update it to match any whitespace using
\sinstead of character classes.