is a syntax used in modern regular expression implementations to specify a subexpression of a regular expression. Given a string that matches the regular expression,
is the process of extracting the substrings corresponding to those subexpressions.
closures are variants on the standard closure operator that impact how submatches are extracted. The state of the art and practice in submatch extraction are automata based approaches and backtracking algorithms. In theory, the number of states in an automata-based approach can be exponential in
, the size of the regular expression, and the running time of backtracking algorithms can be exponential in ℓ, the length of the string. In this paper, we present an
) runtime automata based algorithm for extracting submatches from a string that matches a regular expression, where
> 0 is the number of capturing groups. The previous fastest automata based algorithm was
). Both our approach and the previous fastest one require worst-case exponential compile time. But in practice, the worst case behavior rarely occurs, so achieving a practical speed-up against state-of-the-art methods is of significant interest. Our experimental results show that, for a large set of regular expressions used in practice, our algorithm is approximately twice as fast as Java’s backtracking based regular expression library and approximately twenty times faster than the RE2 regular expression engine.