I'm handling tweets like
@Alice @ home. I want to convert user mentions to normal words (e.g.
@Alice => Alice) but keep the individual
@ as a surrogate for
at. So simply replacing all occurrences of
@ won't work.
I found out about the concept of word boundaries, but I haven't been able to make them work for this. For one,
print re.sub(r'\[email protected]\b', '', '@Alice @ home')
doesn't change anything, while
print re.sub(r'\bAlice\b', '', '@Alice @ home')
@ @ home. So I assume that the at-sign (
@) does not count as part of a word.
In short, I'm basically looking for the
pattern so that
print re.sub(pattern, '', '@Alice @ home')
Alice @ home.
Thanks for any hints.