Version 102 of Regular Expressions

Updated 2019-11-23 18:03:29 by pooryorick

Tcl Regular Expression Match Requirements describes a set of regular expressions, and what, ideally, they would match.

Description

Tcl's regular expression engine has a particular design that leads to some unexpected results. The collection below of regular expression applications on this page and their ideal results is intended as a guide for the further development of regular expression routines in Tcl.

(t*?)?

Ideal:

% regexp -inline -indices {(t*?)?} ttt
{0 -1} {0 -1}

Actual:

% regexp -inline -indices {(t*?)?} ttt
{0 2} {0 2}

.*(a*){1,3}?

Ideal and actual:

regexp -indices -inline {.*(a*){1,3}?} aaaa
{0 3} {4 3}

{(a.*?f)*}

If there is a quantifier on a capturing expression, it should return a list of matches:

% regexp -indices -inline {(a.*?f)*} aaafaaafjkl
{0 7} {{0 3} {4 7}}

Actual:

% regexp -indices -inline {(a.*?f)*} aaafaaafjkl
{0 7} {4 7}