Skip to content
Tcl Source Code Artifact [d30d5562ff]
Login

Artifact [d30d5562ff]

Artifact d30d5562ffe7ca218cc154196cc4077eb51557360357f09aea84d98c271603b2:

Ticket change [d30d5562ff] - Closed ticket [b73f1296966202b2|b73f129696]: <i>regexp -all misses an empty match at the end of the string</i> plus 8 other changes by jan.nijtmans on 2026-10-13 12:17:27.
D 2026-10-13T12:17:27.064
J assignee jan.nijtmans
J closedate 2461327.0121187964
J closer jan.nijtmans
J comment <tt>regexp\s-all</tt>\sdoes\snot\stry\sto\smatch\sat\sthe\send\sof\sthe\sstring,\sso\san\sRE\sthat\scan\smatch\sthe\sempty\sstring\sthere\smisses\sits\slast\smatch.\s<tt>regsub\s-all</tt>\sdoes\stry\sthere,\sso\sthe\stwo\sdisagree:\r\n<verbatim>\r\nregexp\s-all\s{a*}\sab\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s;#\s2,\sbut\sregsub\s-all\s{a*}\sab\s<&>\sgives\s<a><><>\s(3\smatches)\r\nregexp\s-all\s-inline\s-indices\s-line\s{$}\s"a\\n"\s\s\s;#\s{1\s0},\sbut\sthe\sempty\sline\sat\sthe\send\salso\smatches:\s{1\s0}\s{2\s1}\r\n</verbatim>\r\nPostgreSQL,\sPython,\sPerl,\sJava,\sRuby\sand\sJavaScript\sall\sreport\sthe\smatch\sat\sthe\send\s(3\smatches\sfor\sthe\sfirst\sexample).\sTests\sregexp-23.5,\s23.7\sand\s23.9,\sadded\sfor\s[2826551fff],\sexpect\sit\stoo,\sbut\sare\smarked\sknownBug.\r\n\r\nThe\scause\sis\sthe\send\sof\sthe\s<tt>-all</tt>\sloop\sin\s<tt>Tcl_RegexpObjCmd()</tt>:\sit\sstops\swhen\sthe\snext\soffset\sreaches\sthe\send\sof\sthe\sstring\s(<tt>offset\s>=\sstringLength</tt>),\swhile\s<tt>Tcl_RegsubObjCmd()</tt>\sloops\swhile\s<tt>offset\s<=\swlen</tt>.\sFixing\sit\schanges\sthe\snumber\sof\smatches\sthat\s<tt>regexp\s-all</tt>\sreports\sfor\ssuch\sREs,\sand\sseveral\sexisting\stests\s(regexp-18.8\sto\s18.10,\s23.2,\s23.3,\s26.10\sto\s26.13)\sthat\sexpect\sthe\scurrent\sresults.
J icomment Fixed\sin\s[63d4837de7|trunk],\score-9-0-branch\sand\score-8-6-branch\r\n\r\nMany\sthanks!
J login jan.nijtmans
J mimetype text/x-fossil-wiki
J resolution Fixed
J status Closed
K b73f1296966202b2beeb14fec5534dec6a408012
U jan.nijtmans
Z d06c8e730ab19e59f6e548c005358293