I have a block of text like this:
Hello @Simon, I had a great day today. #StackOverflow
I want to find the most elegant solution to stripping it down to look like this:
Hello, I had a great day today.
i.e. I want to strip out all words that have a prefix of # and @. (And yes, im inspecting tweets)
I am new to python, and I would be ok doing this on single words, but not sure on the best way to achieve this on a string that contains multiple words.
My first thoughts would be to use replace, but that would just strip out the actual @ and # symbols. Looking for the best way to strip out any word that has a prefix of # or @.
-EDIT-
Not sure if it this invalidates the answers give, but for acceptance, I also need to strip out where multiple words contain a prefix of # or $. e.g. hello #hiya #ello
You can use regular expressions: