Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 9d0f61643b86767f1778489e1611295145ac7dd1
Ticket: 2798939fffffffffffffffffffffffffffffffff
Non-greedy quantifiers revert to greedy when branched
User & Date: dkf on 2009-05-31 16:55:25
Changes

  1. icomment:
    IIRC, the problem is that the "first" quantifier in the syntax tree is the alternation, which can't be made non-greedy. The fix is to use {1,1}? to force the whole RE to be non-greedy (a non-capturing paren is also needed, but that's pretty trivial).
    
    % regexp -all (?:.+?|x){1,1}? {this is a test}
    14
    
    Note that this is different from Perl/PCRE; they use a different model for greedy/non-greedy handling that does this in a way that is more as people intuitively expect (in return for being worse in other cases).
    
    
  2. login: "dkf"
  3. mimetype: "text/plain"
  4. username: "dkf"