What is the best way to convert the following string to the expected string in Python.
"PowerEdgeSystem"
=>Power Edge System
"VMwareSystem"
=>VMware System
VMwareSystemEQUIPMENT
=>VMware System EQUIPMENT
Tried:
s = 'PowerEdgeSystem'
s = ''.join([' ' + c if i != 0 and c.isupper() else c for i, c in enumerate(s)])
First string is fine, but not as good for second string. Still we can check the case of 'both' side of the particular character and add space based on that as below,
s = ''.join([' ' + c if i != 0 and c.isupper() and not c[i+1].isupper() else c for i, c in enumerate(s)])
But the code will become more messy. I'm expecting some thing more clear way (if anything available). Thank you,