import res = "a\n\tb\n\t\tc\n\td\te\nf\t\tg";print(re.sub(r"^\t+", lambda m: " "*len(m.group()), s, flags=re.M))
Standard input is empty
a b c d e f g
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!