In case anyone finds this useful, I made a small sed-like program in Python. I call it pysed.

The rationale for this tiny program is that I often want to make regexp substitutions but find the classic regular expressions syntax of sed (and emacs) outdated and not as powerful as Python's. For example, suppose you want replace ".m_" with "." except when preceded by "m_state". You do:

pysed -i -e '(?<!m_state)\.m_' -s '.' file.cc

With traditional sed, or with gnu emacs, it does not look like this is possible, as far as I can tell...

No comments: