You may use this
>>> s = "Hello @StackOverflow! How are you today? I'd like to !sh @StackExchange" >>> print ( re.sub(r'@\w+\s*', '', s) ) Hello ! How are you today? I'd like to !sh
@: Match literal
\w+\s*: Match 1+ word characters followed by 0 or more whitespaces
CLICK HERE to find out more related problems solutions.