First part of the solution for the regex exercise