Added more validation for regex.