Replacing Patterns in Strings with Python - Like SED - Linux