import reorig_line = '"aaa"|"bbb"|"123"|"!"\\"|"2010-01-04T00:00:01"'new_line = re.sub(r'(?<=[^|])"(?=[^|])', '~', orig_line)print(new_line)
Standard input is empty
"aaa"|"bbb"|"123"|"!~\"|"2010-01-04T00:00:01"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!