Reputation: 503
I'm not very good at scripting, nor am I very good at regex, so I'm not sure how to accomplish this.
what I'd like to do is run a unix command that will search within current (and sub-) directories for a particular pattern match, and replace it with another string/pattern.
Lots of articles on this, but my 'twist' is that the match must have a wildcard - which will be reproduced in the replacement string.
I'm resorting to this method as I don't think I can get this specific with Eclipse (for PHP). If this CAN be done with Eclipse, please let me know.
For instance, here is the pattern I'm looking for: ::$_<sometext>
and I wish to replace it with ::myFunction('<sometext>')
.
Here is an example:
echo UserClass::$_thevariable;
turns into:
echo UserClass::getVar('thevariable');
.
Thanks for your help
Upvotes: 0
Views: 29
Reputation: 19237
find . -exec sed -i -E -e "s/::[$]_([a-zA-Z]+)/::getVar('\1')/g" {} \;
But be careful with sed -i
, it replaces files in place... Also this works for the specified search/replace strings, it might be more compicated if you need to escape things
Upvotes: 1