|
2019-11-24
| ||
| 15:25 | • Closed ticket [3d40c2da81]: regexp (?:a*b)+c indices wrong plus 6 other chan... artifact: 9dc7b84acc user: sebres | |
|
2019-11-23
| ||
| 21:08 | • New ticket [3d40c2da81]. artifact: d8e0dcf6ec user: pooryorick | |
regexp (?:a*b)+c indices wrong
% regexp -indices -inline {(?:a*b)+c} aaaabbbbcc
{0 8}
The correct result should be:
% regexp -indices -inline {(?:a*b)+c} aaaabbbbcc
{7 8}
No.
Although the sub-expression traverses over all a (and finally over all b without a), despite this not capturing it as a group - the whole expression matches all characters to first c inclusive it.
So the result {0 8} is pretty correct - {0..4} aaaab within first iteration by a*b, {5..7} bbb within second to 4th iteration by (a*b)+ and then finally {8} c.
Note that (?:a*b)+ is neither a lookahead nor a lookbehind assertion (which is not implemented in tcl at all), so the whole match is captured for whole expression.
How the iterations for first subexpression look, illustrating this example:
% regexp -all -indices -inline {a*b} aaaabbbbcc
{0 4} {5 5} {6 6} {7 7}