import re
s = "this_is.an_Example string for.You"
print(re.sub( r'(?<![^_.])[^\W_]+|[^\W_]+(?=[._])', lambda x: x.group().capitalize(), s))