I want to split "Onehundredthousand" to "one" "hundred" "thousand" using python.
How can I do that?
You can use a string's partition method to split it into 3 parts (left part, separator, right part):
"onehundredthousand".partition("hundred")
# output: ('one', 'hundred', 'thousand')
>>> s = "Onehundredthousand"
>>> s.replace('hundred', '_hundred_').split('_')
['One', 'hundred', 'thousand']
This will only work on the given string.
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