Skip to content
Tcl Source Code History Of Ticket 471101
Login

History Of Ticket 471101

Artifacts Associated With Ticket 471101

  1. Ticket change [bf57207e52] (rid 102234) by hobbs on 2001-10-14 20:02:58:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. 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
      
      
    4. foundin initialized to: "obsolete: 8.3.3"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "hobbs"
    9. subsystem initialized to: "43. Regexp"
    10. title initialized to: "RE \A and ^ don't replace the same"
    11. type initialized to: "Bug"
  2. Ticket change [5ded79ac93] (rid 115549) by hobbs on 2001-10-15 03:19:52:

    1. 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.
      
      
    2. login: "hobbs"
    3. mimetype: "text/plain"
    4. username: "hobbs"
  3. Ticket change [657cfc5cc4] (rid 102553) by dgp on 2002-01-15 20:22:10:

    1. assignee changed to: "hobbs"
  4. Ticket change [17e1a5f661] (rid 257488) by serhiy.storchaka on 2026-10-10 17:51:51:

    1. 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].
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
  5. Ticket change [d3c7262c60] (rid 257897) by jan.nijtmans on 2026-10-13 12:19:50:

    1. assignee changed to: "jan.nijtmans"
    2. closedate changed to: "2461327.0137817594"
    3. closer changed to: "jan.nijtmans"
    4. 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
      
    5. foundin changed to: "8.6, 9.0.5, 9.1.0"
    6. icomment:
      Fixed in [d2a1819076|trunk], core-9-0-branch and core-8-6-branch
      
      Many thanks!
      
    7. login: "jan.nijtmans"
    8. mimetype: "text/x-fossil-wiki"
    9. resolution changed to: "Fixed"
    10. severity changed to: "Minor"
    11. status changed to: "Closed"