I have a string in the format:
t='@abc @def Hello this part is text'
I want to get this:
l=["abc", "def"]
s='Hello this part is text'
I did this:
a=t[t.find(' ',t.rfind('@')):].strip()
s=t[:t.find(' ',t.rfind('@'))].strip()
b=a.split('@')
l=[i.strip() for i in b][1:]
It works for the most part, but it fails when the text part has the '@'. Eg, when:
t='@abc @def My email is [email protected]'
it fails. The @names are there in the beginning and there can be text after @names, which may possibly contain @.
Clearly I can append initally with a space and find out first word without '@'. But that doesn't seem an elegant solution.
What is a pythonic way of solving this?