Overview
| Artifact ID: | a91be4badb27dabc0400babe250f40dc5157421a |
|---|---|
| Ticket: | 219219ffffffffffffffffffffffffffffffffff
greedy vs. non-greedy confusion |
| User & Date: | nobody on 2000-10-26 05:03:45 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
OriginalBugID: 4001 Bug Version: 8.2.3 SubmitDate: '2000-01-10' LastModified: '2000-01-27' Severity: MED Status: Assigned Submitter: techsupp ChangedBy: hobbs RelatedBugIDs: 2866 OS: BSD OSVersion: NetBSD-1.4.1/i386 FixedDate: '2000-10-25' ClosedDate: '2000-10-25' Name: hume smith ReproducibleScript: > tclsh % regexp {x.*?([a-z]+)} {1234x56789word101112} a b 1 % set a x56789w % set b w % set tcl_patchLevel 8.2.3 % ObservedBehavior: the + was matched in a nongreedy fashion; shouldn't it be greedy? DesiredBehavior: % set a x56789word % set b word % Patch: PatchFiles: Henry Spencer has noted some problems with mixing greedy and non-greedy quantifiers in the new regexp code. He's cc'ed on this, but in the meantime, the work-around is: regexp {x[^a-z]*([a-z]+)} {1234x56789word101112} a b -- 01/10/2000 hobbs From HS: This is the same old problem: people accustomed to Perl are not grasping the idea that the whole RE is greedy or non-greedy, but *not* some mixture of the two. In this case, it is non-greedy since the first thing in it which cares is non-greedy. The + is being as greedy as it can, within the constraints set by the behavior of the whole RE. In short, the behavior, while surprising, is as documented. It's not an outright bug; it may, however, be a misfeature. -- 01/10/2000 hobbs - foundin changed to: "final: 8.2.3"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "43. Regexp"
- title changed to: "greedy vs. non-greedy confusion"
- type changed to: "Bug"