You may use this re.sub
:
@\w+\s*
Code:
>>> 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
RegEx Details:
@
: Match literal@
:\w+\s*
: Match 1+ word characters followed by 0 or more whitespaces
CLICK HERE to find out more related problems solutions.