Skip to content
Tcl Source Code History Of Ticket 700ac47ece488c90
Login

History Of Ticket 700ac47ece488c90

Artifacts Associated With Ticket 700ac47ece488c90

  1. Ticket change [e45ba7a55c] (rid 141066) by Hagay Garty on 2014-12-27 09:17:56:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      Hi, I have seen a bug in regexp matching. I verified VS external regexp engines that indeed im not mistaken.
      
      Recreation:
      
      set data {0000}
      regexp {\n?(0+?)} $data a b
      
      This will place '0000' in b variable 
      The correct result is to place '0' in b variable
      
      So in this case the '+?' is treated as '+"
      
      BTW when omitting the '\n?' from the beginning of the regexp the problem is gone and the correct assignment is made to b - '0'
      
    5. foundin initialized to: "8.5.17"
    6. is_private initialized to: "0"
    7. login: "Hagay Garty"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "16c28166ca941aa1315f7147d67737eb495d8ff0"
    10. resolution initialized to: "None"
    11. severity initialized to: "Important"
    12. status initialized to: "Open"
    13. submitter initialized to: "Hagay Garty"
    14. subsystem initialized to: "- New Builtin Commands"
    15. title initialized to: "Bug in regexp matching"
    16. type initialized to: "Bug"
  2. Ticket change [eb7920fbeb] (rid 141067) by Hagay Garty on 2014-12-27 09:20:18:

    1. login: "Hagay Garty"
    2. mimetype: "text/plain"
    3. subsystem changed to: "43. Regexp"
  3. Ticket change [1f8a046451] (rid 141068) by Hagay Garty on 2014-12-27 09:21:04:

    1. login: "Hagay Garty"
    2. mimetype: "text/plain"
    3. priority changed to: "7 High"
    4. severity changed to: "Severe"
  4. Ticket change [ab9de3745c] (rid 141069) by ysch on 2014-12-29 21:43:14:

    1. icomment:
      > Hi, I have seen a bug in regexp matching. 
      No, you didn't. ;)
      
      > I verified VS external regexp engines that indeed im not mistaken.
      Other engines are irrelevant here.
      
      From man re_syntax:
      ---
      In the event that an RE could match more than one substring of a given string, the RE matches the one starting earliest in the string. If the RE could match more than one substring starting at that point, its choice is determined by its preference: either the longest substring, or the shortest.
      
      Most atoms, and all constraints, have no preference. A parenthesized RE has the same preference (possibly none) as the RE. A quantified atom with quantifier {m} or {m}? has the same preference (possibly none) as the atom itself. A quantified atom with other normal quantifiers (including {m,n} with m equal to n) prefers longest match. A quantified atom with other non-greedy quantifiers (including {m,n}? with m equal to n) prefers shortest match. A branch has the same preference as the first quantified atom in it which has a preference. 
      ---
      Your RE starts with quantified atom with normal quantifier (\n?), so this atom prefers longest match. As your RE consists of single branch, "it has the same preference as the first quantified atom in it which has a preference" --- longest match.
      
      So, it's not a bug. So, your RE should have been: \n??(0+?)
      
    2. login: "ysch"
    3. mimetype: "text/plain"
  5. Ticket change [6ee3e0ded0] (rid 141070) by ferrieux on 2014-12-31 15:05:05:

    1. closedate changed to: "2457023.12853506"
    2. closer changed to: "ferrieux"
    3. icomment: "Agreeing with the analysis, closing accordingly."
    4. login: "ferrieux"
    5. mimetype: "text/plain"
    6. resolution changed to: "Invalid"
    7. status changed to: "Closed"