Given a text like
THIS is a #hashtag and this is a #multiWordHashtag
I need to output
THIS is a hashtag and this is a multi Word Hashtag
For now, I use this function:
def do_process_eng_hashtag(input_text: str):
result = []
for word in input_text.split():
if word.startswith('#') and len(word) > 1:
word = list(word)
word[1] = word[1].upper()
word = ''.join(word)
word = ' '.join(re.findall('[A-Z][^A-Z]*', word))
result.append(word)
return ' '.join(result)
But I wonder if there is a more efficient and neat way to do so?