I have the following problem. I am looking to find all the words in a line that usually looks like this.
HelloWorldToYou
Note: each word is capitalized as the beginning, followed by the next word, etc. I am looking to create a list of words from it. So the final expected result is a list that looks like
['Hello','World','To','You']
In Python, I used the following
mystr = 'HelloWorldToYou'
pat = re.compile(r'([A-Z](.*?))(?=[A-Z]+)')
[x[0] for x in pat.findall(mystr)]
['Hello', 'World', 'To']
However, I can not fix the last word "You." Is there any way to handle this? thanks in advance
source
share