m[^ # With the $, match the whole line (\S+) # The first field contains no spaces \s+ # and is separated from the next by at least 1 \b(.*)\b # 2nd field starts/stops on a word boundary # it can contain anything, \s{2,} # but only single concecutive spaces. \b(.*)\b # 3rd field is similarly defined \s{2,} # Again, 2 or more spaces defined the end of field (\S) # 4th Single non-space char \s+ # 1 or more spaces (\S) # 5th Single char. $]x