I'm using Python 3.10 on Windows 10 and trying the search below:
re.sub(r'(.*[A-Z]+[a-z]+)([A-Z])', r'\1 \2', 'JohnnyB Cool & JoeCool')
'JohnnyB Cool & Joe Cool'
If I use just "JohnnyB Cool", the "B" gets a space before it.
re.sub(r'(.*[A-Z]+[a-z]+)([A-Z])', r'\1 \2', 'JohnnyB Cool')
'Johnny B Cool'
Why isn't the "JohnnyB" substituted in the first search? I've also tried:
re.sub(r'(.*)([A-Z]+[a-z]+)([A-Z])', r'\1 \2 \3', 'JohnnyB Cool & JoeCool')
'JohnnyB Cool & Joe Cool'
To be clear, I want the final answer to be, Johnny B Cool & Joe Cool.