Overview
| Artifact ID: | 26238b7f7530f7af939e7a49b7471b61a93bf68e |
|---|---|
| Ticket: | 11250a236da29e6badf7755a1b67995defa5170f
unexpected non greedy matching behaviour |
| User & Date: | anonymous on 2015-05-17 14:55:33 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed 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 changed to: "8.6"
- is_private changed to: "0"
- login: "anonymous"
- priority changed to: "5 Medium"
- private_contact changed to: "87a8ab2e1e5150e17c388ae3d6a4369041a5c4fa"
- resolution changed to: "None"
- severity changed to: "Severe"
- status changed to: "Open"
- submitter changed to: "anonymous"
- subsystem changed to: "43. Regexp"
- title changed to: "unexpected non greedy matching behaviour"
- type changed to: "Bug"