Artifacts Associated With Ticket 471101
Ticket change [bf57207e52] (rid 102234) by hobbs on 2001-10-14 20:02:58:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
When no options are specified, \A and ^ should be the same, but they don't seem to behave the same: (hobbs) 79 % regsub -all {\Aa} {aabbcc} {b} r 2 (hobbs) 80 % set r bbbbcc (hobbs) 81 % regsub -all {^a} {aabbcc} {b} r 1 (hobbs) 82 % set r babbcc whereas \Z seems OK: (hobbs) 83 % regsub -all {(\Aa|c\Z)} {aabbcc} {b} r 3 (hobbs) 84 % set r bbbbcb (hobbs) 85 % regsub -all {(^a|c$)} {aabbcc} {b} r 2 (hobbs) 86 % set r babbcb - foundin initialized to: "obsolete: 8.3.3"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "hobbs"
- subsystem initialized to: "43. Regexp"
- title initialized to: "RE \A and ^ don't replace the same"
- type initialized to: "Bug"
Ticket change [5ded79ac93] (rid 115549) by hobbs on 2001-10-15 03:19:52:
- icomment:
Logged In: YES user_id=72656 This is actually ... correct. The problem is with the handling of offsets, and is indicated by the docs for regsub -start (which just allows the user to set the offset). -start index Specifies a character index offset into the string to start matching the regular expression at. When using this switch, `^' will not match the beginning of the line, and \A will still match the start of the string at index. If -indices is specified, the indices will be indexed starting from the absolute beginning of the input string. index will be constrained to the bounds of the input string. This result is actually the same for 8.2. I'm not sure that this is a great feature, but I think the only way to get around it is to get into the guts of the RE.
- login: "hobbs"
- mimetype: "text/plain"
- username: "hobbs"
- icomment:
Ticket change [657cfc5cc4] (rid 102553) by dgp on 2002-01-15 20:22:10:
- assignee changed to: "hobbs"
Ticket change [17e1a5f661] (rid 257488) by serhiy.storchaka on 2026-10-10 17:51:51:
- icomment:
Still the same in 8.6, 9.0 and 9.1. With <tt>-all</tt>, <tt>regexp</tt> and <tt>regsub</tt> restarted matching on the substring after the previous match, so <tt>\A</tt> matched again at each restart point; <tt>^</tt> was only protected by <tt>TCL_REG_NOTBOL</tt>. All other engines (PCRE, Perl, Python, Java, Ruby, and PostgreSQL, whose engine is derived from Tcl's) match <tt>\A</tt> only once. Word constraints are affected the same way, since they could not see the character before the restart point: <tt>regexp -all -inline {\m\w} "ab cd"</tt> returns <tt>a b c d</tt> instead of <tt>a c</tt>, and <tt>\y</tt> matches between any two word characters. Proposed fix in branch [/timeline?r=regexp-all-search-start|regexp-all-search-start]: successive matches are searched from the current offset in the whole string, so <tt>\A</tt> matches only at the start (or at the <tt>-start</tt> index) and word constraints see the previous character. Tests regexp-29.*. Test regexp-16.4, which expected the old behaviour, is updated. This changes behaviour, so it is proposed for the next feature release, not for backporting. Also fixes [884d0ac78c]. - login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [d3c7262c60] (rid 257897) by jan.nijtmans on 2026-10-13 12:19:50:
- assignee changed to: "jan.nijtmans"
- closedate changed to: "2461327.0137817594"
- closer changed to: "jan.nijtmans"
- comment changed to:
When no options are specified, \A and ^ should be the same, but they don't seem to behave the same: (hobbs) 79 % regsub -all {\Aa} {aabbcc} {b} r 2 (hobbs) 80 % set r bbbbcc (hobbs) 81 % regsub -all {^a} {aabbcc} {b} r 1 (hobbs) 82 % set r babbcc whereas \Z seems OK: (hobbs) 83 % regsub -all {(\Aa|c\Z)} {aabbcc} {b} r 3 (hobbs) 84 % set r bbbbcb (hobbs) 85 % regsub -all {(^a|c$)} {aabbcc} {b} r 2 (hobbs) 86 % set r babbcb - foundin changed to: "8.6, 9.0.5, 9.1.0"
- icomment:
Fixed in [d2a1819076|trunk], core-9-0-branch and core-8-6-branch Many thanks!
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- severity changed to: "Minor"
- status changed to: "Closed"