The * makes the expression match the empty string. The regex engine tries at pos 0 (aka start of the string), which is the lone dash. It tries to match the regex, succeeds with zero occurences of (?:\d+-UK\W?), stores the matched (empty) string in $1 and reports success.