Thursday, 12 September 2013

extracting multiple substrings from string using sed

extracting multiple substrings from string using sed

I'm working on a cocos2dx project and recently we updated to the latest
version of cocos2dx, this introduced a number of warnings which I'm
cleaning up.
I have a lot of code like:
CCPoint somePoint = ccpAdd(this->getPosition(), _someRandomOffset);
The method ccpAdd is deprecated, in favour of the + operator, I want to
replace such instances. I've tried searching on google, but I can't find
out how to extract two strings using sed and build them back together.
CCPoint somePoint = this->getPosition() + _someRandomOffset;
My question is, how can I automate this replacement using some script
against my source files?
Bonus points if the sed command can handle nested ccpAdd commands, like:
CCPoint somePoint = ccpAdd(this->getPosition(), ccpAdd(one, two));
Or maybe sed is the wrong tool for the job?

No comments:

Post a Comment