This regexp is correct, but fails with slre : (([a-z_-]+)/([a-z@_-]+)@)?([a-z]+) A dirty way to "fix" it is to surround the last group with (...) (([a-z_-]+)/([a-z@_-]+)@)? ( ([a-z]+) )