Currently, a regular expression is not altered during matching, except for shifting marks.
However, inactive parts that can never again become active do not influence the results of empty and final and can be dropped or replaced by noMatch or eps depending on whether they accept the empty word. Inactive parts may become active only if they have active parts to their left or if they are inside an active repetition.
Pruning may improve performance significantly for infinite regular expressions which do not use repetitions, and maybe even for large finite expressions such as (a?){n}a{n} for large n.
Currently, a regular expression is not altered during matching, except for shifting marks.
However, inactive parts that can never again become active do not influence the results of
empty
andfinal
and can be dropped or replaced bynoMatch
oreps
depending on whether they accept the empty word. Inactive parts may become active only if they have active parts to their left or if they are inside an active repetition.Pruning may improve performance significantly for infinite regular expressions which do not use repetitions, and maybe even for large finite expressions such as
(a?){n}a{n}
for largen
.