/.* # Read as far as possible before \s # matching whitespace, (\S+) # capturing a word, \s+ # matching more whitespace, (\S+) # and finally capturing the last word. /x