added regex function for validating against an arbitrary pattern