A Questions for the regular expression/ sed experts out there: I need to beautify some c++ code. The code is littered with various version of the assignment operator with different types of spacing. i.e.
a=b
a =b
a= B
a = b
a= b
A = B. // the correct format needed, and so must be ignored by SED
There should only be one space around the =. If more are found, the extras must be removed.
I need to make a script that will scan through all files in folder and subfolders and search and replace as needed.
There are some variations, like the a+=b etc.
I run on OsX but have linux and windows machines available.
help much appreciated.
a+=banda*=betc?>> cat regtest.txt a=b asas asasa=bddfdf a =dfdf sasasa= ssdsd sdsd = sdsdsd RESULT: >> sed 's/([^ =])+ *([=+*/%-]?=)( )*([^ ])/$1 $2 $3/' regtest.txt a=b asas asasa=bddfdf a =dfdf sasasa= ssdsd sdsd = sdsdsd