import res = "this_is.an_Example string for.You"print(re.sub( r'(?<![^_.])[^\W_]+|[^\W_]+(?=[._])', lambda x: x.group().capitalize(), s))
Standard input is empty
This_Is.An_Example string For.You
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!