def with_zero_or_one(cls, converter, pattern=None):
        cardinality = Cardinality.zero_or_one
        if not pattern:
            pattern = getattr(converter, "pattern", cls.default_pattern)
        optional_pattern = cardinality.make_pattern(pattern)
        group_count = cardinality.compute_group_count(pattern)
        def convert_optional(text, m=None):
            if text:
                text = text.strip()
            if not text:
                return None
            return converter(text)
        convert_optional.pattern = optional_pattern
        convert_optional.regex_group_count = group_count
        return convert_optional