While isPotentiallyZeroLength generally assumes the worst-case for backreferences that references capturing group
outside the given element, this function does not/cannot. The length range of a backreference only depends on the
referenced capturing group and the relative positions of the backreference and the capturing group within the
pattern. It does not depend on the given element.
This is an important distinction because it means that isPotentiallyZeroLength(e) -> getLengthRange(e).min == 0 is
guaranteed but getLengthRange(e).min == 0 -> isPotentiallyZeroLength(e) is only guaranteed if e does not contain
backreferences.
Returns how many characters the given element can consume at most and has to consume at least.
Note that character classes are not parsed by this function and are assumed to be non-empty.
Backreferences
While isPotentiallyZeroLength generally assumes the worst-case for backreferences that references capturing group outside the given element, this function does not/cannot. The length range of a backreference only depends on the referenced capturing group and the relative positions of the backreference and the capturing group within the pattern. It does not depend on the given element.
This is an important distinction because it means that
isPotentiallyZeroLength(e) -> getLengthRange(e).min == 0
is guaranteed butgetLengthRange(e).min == 0 -> isPotentiallyZeroLength(e)
is only guaranteed ife
does not contain backreferences.