fork download
  1. import re
  2.  
  3. regex = r"[^\W_\d](?=\S(?!\S))"
  4. s = ("I Like Studying Python Programming\n\n"
  5. "a) This is a test with 3d\n")
  6.  
  7. output = re.sub(regex, lambda m: m.group(0).upper(), s)
  8. print(output)
Success #stdin #stdout 0.02s 9584KB
stdin
Standard input is empty
stdout
I LiKe StudyiNg PythOn ProgrammiNg

A) ThIs Is a teSt wiTh 3d