I want to replace all occurences of '$' in a LaTeX source code in the following way: The dollars on odd position in the file must be changed in '$latex ' and the other dollars can remain the same.
I was thinking to make a script which replaces all odd occurences of a given character with a string, and all even occurences of the same character with another string.