The hyphen counts as a word boundary, so it matches since the first occurrence of "test" is bounded by a space on the left and a hyphen on the right. (A word boundary is any character that is not a member of the "alnum" class, which is basically all letters, numbers, and the underscore.)