I can't figure out how to replace the second uppercase letter in a string in python.
for example:
string = "YannickMorin"
I want it to become yannick-morin
As of now I can make it all lowercase by doing string.lower() but how to put a dash when it finds the second uppercase letter.
You can use Regex
>>> import re
>>> split_res = re.findall('[A-Z][^A-Z]*', 'YannickMorin')
['Yannick', 'Morin' ]
>>>'-'.join(split_res).lower()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With