Skip to content
Tcl Source Code History Of Ticket 11250a236da29e6b
Login

History Of Ticket 11250a236da29e6b

Artifacts Associated With Ticket 11250a236da29e6b

  1. Ticket change [26238b7f75] (rid 141821) by anonymous on 2015-05-17 14:55:33:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      since there seems no suitable mailing list to ask and I presume it's a bug I'm reporting this here: non-greedy matching seems not to work as it should in certain contexts, specifically, matching seemingly becomes greedy if the respective atom is preceded by a pattern containing `+'  to indicate arbitrary (one or more) occurrence of chars from a range or class.
      
      example:
      
      # a string with four sub-patterns I want to capture (the latex-like constructs `\emph{xxx}'):
      
      set s "\emph{A} a \emph{B} b \emph{C} c \ital{D} d"
      
      # this one correctly finds all four of them, when specifying that the stuff before `{xxx}' consists of exactly 4 letters:
      
      regexp -all  {(\\[a-z]{4})\{(.*?)\}} $s dum; puts $dum; # ==> \ital{D}  <== (OK)
      
      # allowing "one or more" chars instead of "exactly 4" changes the match to "greedy", i.e. it reports a _single_ match of
      # everyting up to the last closing `}':
      
      regexp -all  {(\\[a-z]+)\{(.*?)\}} $s dum; puts $dum; # == > \emph{A} a \emph{B} b \emph{C} c \ital{D} <==(WRONG)
      
      # the same problem here:
      regexp -all  {(\\w+)\{(.*?)\}} $s dum; puts $dum; # == > \emph{A} a \emph{B} b \emph{C} c \ital{D} <==(WRONG)
      
      
      is this a bug or am I completely misunderstanding how non-greedy matching is supposed to work/be used?
      
      thanks 
      
      joerg
      
    5. foundin initialized to: "8.6"
    6. is_private initialized to: "0"
    7. login: "anonymous"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "87a8ab2e1e5150e17c388ae3d6a4369041a5c4fa"
    10. resolution initialized to: "None"
    11. severity initialized to: "Severe"
    12. status initialized to: "Open"
    13. submitter initialized to: "anonymous"
    14. subsystem initialized to: "43. Regexp"
    15. title initialized to: "unexpected non greedy matching behaviour"
    16. type initialized to: "Bug"
  2. Ticket change [c4c0594daf] (rid 141822) by ferrieux on 2015-05-17 15:41:42:

    1. assignee changed to: "dkf"
    2. icomment:
      As it turns out, Tcl regexps don't allow for mixed-greediness:
      
      http://stackoverflow.com/questions/11771610/tcl-regular-expression-help-needed-on-non-greedy-quantifiers-in-pattern-with
      
      I admit that this fact could be made more conspicuous in the re_syntax manpage though.
      
      Donal, care for a doc fix ?
      
    3. login: "ferrieux"
    4. mimetype: "text/plain"
  3. Ticket change [410b2a9902] (rid 141831) by anonymous on 2015-05-17 18:38:35:

    1. icomment:
      I see now after looking long and hard at `man re_syntax' that it somehow _is_ explained but making this more obvious would be good. it seems a solution in my case is to to use
      
      regexp -all  {\\(?:\w+){1,1}?{(.*?)}} $s dum
      
      this "trick" of appending `{1,1}?' to the greedy part in order to make it non-greedy overall (if it _is_ the way to solve this, might especially deserve to be pointed out more pronouncedly.
      
    2. login: "anonymous"
    3. mimetype: "text/plain"
  4. Ticket change [40864f6ffc] (rid 141854) by dkf on 2015-05-18 08:22:27:

    1. closedate changed to: "2457160.84892694"
    2. closer changed to: "dkf"
    3. icomment:
      Done, but I don't think it helps as much as people really want; the real problem is that it is a long page with a lot of content on it. I don't know what to do about that without making the problem worse.
      
    4. login: "dkf"
    5. mimetype: "text/html"
    6. resolution changed to: "Fixed"
    7. severity changed to: "Minor"
    8. status changed to: "Closed"
    9. username: "dkf"
  5. Ticket change [a763584697] (rid 141855) by dkf on 2015-05-18 08:24:54:

    1. closedate changed to: "2457160.85062799"
    2. icomment:
      Added text (post-render):
      <pre>
                    <b>NOTE:</b>  This  means  that you can usually make a RE be non‐greedy
                    overall by putting <b>{1,1}?</b> after one of the first  non‐constraint
                    atoms or parenthesized sub‐expressions in it. <i>It pays to experi‐</i>
                    <i>ment</i> with the placing of this non‐greediness override on a suit‐
                    able  range  of input texts when you are writing a RE if you are
                    using this level of complexity.
      
                    For example, this regular expression  is  non‐greedy,  and  will
                    match  the  shortest substring possible given that “<b>abc</b>” will be
                    matched as early as possible (the  quantifier  does  not  change
                    that):
      
                           ab{1,1}?c.*x.*cba
      
                    The  atom  “<b>a</b>”  has no greediness preference, we explicitly give
                    one for “<b>b</b>”, and the remaining quantifiers are overridden to  be
                    non‐greedy by the preceding non‐greedy quantifier.
      </pre>
      
    3. login: "dkf"
    4. mimetype: "text/html"
  6. Ticket change [778097dfc3] (rid 141873) by anonymous on 2015-05-19 10:57:55:

    1. closedate changed to: "2457161.95689747"
    2. closer changed to: "anonymous"
    3. icomment:
      short feedback: I like the change to the manpage and believe it is helpful. in absence of another "communication channel" and  if someone from core is reading this: I am very new to tcl and am not able to find a suitable tcl-users mailing list. isn't there any? I would not have reported my regexp problem as a bug in the first place if I would have found a means to ask the community otherwise. so, what do you recommend? it seems wrong to flood the bug tracker with stuff like this inquiry ...
      
      thx/joerg
      
    4. login: "anonymous"
    5. mimetype: "text/plain"
  7. Ticket change [a88e4107e1] (rid 141875) by aku on 2015-05-19 16:50:27:

    1. closedate changed to: "2457162.20170285"
    2. closer changed to: "aku"
    3. icomment:
      Top of the <a href="http://core.tcl.tk/">core</a> website lists a number of related websites and channels, like comp.lang.tcl.
      
    4. login: "aku"
    5. mimetype: "text/plain"
  8. Ticket change [02e9d5f52a] (rid 141876) by ferrieux on 2015-05-19 17:02:17:

    1. closedate changed to: "2457162.20992892"
    2. closer changed to: "ferrieux"
    3. icomment:
      The recommended, active community meeting point is the comp.lang.tcl newsgroup.
      
    4. login: "ferrieux"
    5. mimetype: "text/plain"