check generated class for null before checking
make regex quantifiers possessive to reduce stack requirements