Fix regex matching for subclasses