|
2026-10-13
| ||
| 12:17 | • Closed ticket [b73f129696]: regexp -all misses an empty match at the end of the ... artifact: d30d5562ff user: jan.nijtmans | |
|
2026-10-12
| ||
| 13:57 | Fix [b73f129696]: regexp -all did not try to match at the end of the string check-in: 8a5ca98e2c user: jan.nijtmans tags: core-8-6-branch | |
| 11:22 | Fix [b73f129696]: regexp -all did not try to match at the end of the string check-in: cbab603b8d user: jan.nijtmans tags: core-9-0-branch | |
|
2026-10-11
| ||
| 19:58 | Fix [b73f129696]: regexp -all did not try to match at the end of the string check-in: 63d4837de7 user: jan.nijtmans tags: trunk, main | |
| 08:21 | • Ticket [b73f129696] regexp -all misses an empty match at the end of the string</... artifact: 4a617ea2dc user: serhiy.storchaka | |
| 08:18 | Fix [b73f129696]: regexp -all did not try to match at the end of the string, so an RE that can match... closed check-in: ccdd2bd1d7 user: serhiy.storchaka tags: regexp-all-end-of-string | |
| 08:18 | • New ticket [b73f129696] regexp -all misses an empty match at the end of the stri... artifact: 764283071c user: serhiy.storchaka | |
regexp -all misses an empty match at the end of the string
regexp -all {a*} ab ;# 2, but regsub -all {a*} ab <&> gives <a><><> (3 matches)
regexp -all -inline -indices -line {$} "a\n" ;# {1 0}, but the empty line at the end also matches: {1 0} {2 1}
PostgreSQL, Python, Perl, Java, Ruby and JavaScript all report the match at the end (3 matches for the first example). Tests regexp-23.5, 23.7 and 23.9, added for [2826551fff], expect it too, but are marked knownBug.
The cause is the end of the -all loop in Tcl_RegexpObjCmd(): it stops when the next offset reaches the end of the string (offset >= stringLength), while Tcl_RegsubObjCmd() loops while offset <= wlen. Fixing it changes the number of matches that regexp -all reports for such REs, and several existing tests (regexp-18.8 to 18.10, 23.2, 23.3, 26.10 to 26.13) that expect the current results.
8a5ca98e2cFix [b73f129696]: regexp -all did not try to match at the end of the string check-in2026-10-12 13:57:05cbab603b8dFix [b73f129696]: regexp -all did not try to match at the end of the string check-in2026-10-12 11:22:5663d4837de7Fix [b73f129696]: regexp -all did not try to match at the end of the string check-in2026-10-11 19:58:02ccdd2bd1d7Fix [b73f129696]: regexp -all did not try to match at the end of the string, so an RE that can match the empty string missed its last match there, unlike regsub -all and other RE engines. Also try at the end of the string. Incompatible: such REs now report one more (empty) match. Remove knownBug from regexp-23.5, 23.7, 23.9; update tests that expected the old behaviour. check-in2026-10-11 08:18:53
Proposed fix in branch regexp-all-end-of-string: the -all loop also tries at the end of the string, as regsub -all does. The knownBug marks are removed from regexp-23.5, 23.7 and 23.9, and the tests that expected the old results are updated. Together with the fix for [471101ffff] (branch regexp-all-search-start), zero-width REs like \y, \m or $ then give the same matches with -all as in other RE engines.
Fixed in [trunk], core-9-0-branch and core-8-6-branch
Many thanks!