import re cmd = '!cmd @retard' result = re . search ( '^\!cmd\s@(.+)' , cmd ) if result : print ( result . group ( 1 ) )