A pythonic way to insert a space before capital letters December 7, 2023 by Tarik You could try: >>> re.sub(r"(\w)([A-Z])", r"\1 \2", "WordWordWord") 'Word Word Word'