Artifacts Associated With Ticket 11250a236d
Ticket change [26238b7f75] (rid 141821) by anonymous on 2015-05-17 14:55:33:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- 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 - foundin initialized to: "8.6"
- is_private initialized to: "0"
- login: "anonymous"
- priority initialized to: "5 Medium"
- private_contact initialized to: "87a8ab2e1e5150e17c388ae3d6a4369041a5c4fa"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "anonymous"
- subsystem initialized to: "43. Regexp"
- title initialized to: "unexpected non greedy matching behaviour"
- type initialized to: "Bug"
Ticket change [c4c0594daf] (rid 141822) by ferrieux on 2015-05-17 15:41:42:
- assignee changed to: "dkf"
- 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 ?
- login: "ferrieux"
- mimetype: "text/plain"
Ticket change [410b2a9902] (rid 141831) by anonymous on 2015-05-17 18:38:35:
- 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. - login: "anonymous"
- mimetype: "text/plain"
- icomment:
Ticket change [40864f6ffc] (rid 141854) by dkf on 2015-05-18 08:22:27:
- closedate changed to: "2457160.84892694"
- closer changed to: "dkf"
- 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.
- login: "dkf"
- mimetype: "text/html"
- resolution changed to: "Fixed"
- severity changed to: "Minor"
- status changed to: "Closed"
- username: "dkf"
Ticket change [a763584697] (rid 141855) by dkf on 2015-05-18 08:24:54:
- closedate changed to: "2457160.85062799"
- 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> - login: "dkf"
- mimetype: "text/html"
Ticket change [778097dfc3] (rid 141873) by anonymous on 2015-05-19 10:57:55:
- closedate changed to: "2457161.95689747"
- closer changed to: "anonymous"
- 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
- login: "anonymous"
- mimetype: "text/plain"
Ticket change [a88e4107e1] (rid 141875) by aku on 2015-05-19 16:50:27:
- closedate changed to: "2457162.20170285"
- closer changed to: "aku"
- 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.
- login: "aku"
- mimetype: "text/plain"
Ticket change [02e9d5f52a] (rid 141876) by ferrieux on 2015-05-19 17:02:17:
- closedate changed to: "2457162.20992892"
- closer changed to: "ferrieux"
- icomment:
The recommended, active community meeting point is the comp.lang.tcl newsgroup.
- login: "ferrieux"
- mimetype: "text/plain"