find which subgroups don't match in regex

Hello gents, here's the thing been confusing me for a while: $regex="(\w+)\s([0-9]+)"; $a="Tom 1990"; # it's a match $b="Jack xyz"; # not a match, because of $2 doesn't match ... but here's my question, exactly how to inform the users of this unmatched subgroup? (i.e. $2 is the problem, $1 is fine, etc.)