Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: a054c3c46ec5bfae7dd4c7f8a72be0068065bc99
Ticket: 906616ffffffffffffffffffffffffffffffffff
lsearch -regexp error introduced in 8.4.2
User & Date: rickmacd on 2004-03-03 03:11:29
Changes

  1. icomment:
    Logged In: YES 
    user_id=493198
    
    I hadn't realized that searching an empty list in my example
    made a difference.
    
    I looked again, and with a closer example to what my app is
    doing I see that it worked in tcl8.0 but fails as of tcl8.2.
    I don't have 8.1 handy.
    
    I've restated an example here to make it more clear that
    what I am doing is searching a list of lists to match with a
    list element. I'm using -regexp to anchor the match at the
    beginning. In my mind, "^myelement" is a simple rexexp of
    the anchor "^" folowed by some data that is "unfortunately"
    being contrued as part of the regexp itself.
    
    I can certainly accept it if your answer is that tcl is
    behaving as desired and expected, but if you don't mind
    please confirm this in light of the revised example here. I
    do understand that after parsing, all my examples are
    probably seen the same by tcl. I wouldn't have thought this
    a bug if it had originally failed years ago when the code
    was first written.
    
    If there is no bug here I have some refactoring to do. In
    some cases I can use -exact, otheres -glob, but in some I'll
    have to loop through and compare each element manually. Or,
    can anybody see any clever quoting that could be done to the
    lsearch below so that $myelement is not seen as part of the
    regexp?
    
    tclsh8.0
    % set mylist [list [list [list 3 5] 1 3] [list [list 4 6] 4 6]]
    {{3 5} 1 3} {{4 6} 4 6}
    % set myelement [list [list 4 6]]
    {4 6}
    % lsearch -regexp $mylist ^$myelement
    1
    % 
    
    tclsh8.4
    % set mylist [list [list [list 3 5] 1 3] [list [list 4 6] 4 6]]
    {{3 5} 1 3} {{4 6} 4 6}
    % set myelement [list [list 4 6]]
    {4 6}
    % lsearch -regexp $mylist ^$myelement
    couldn't compile regular expression pattern: quantifier
    operand invalid
    
    "-glob" works for this particular case:
    % lsearch -glob $mylist $myelement*
    1
    
    
    
  2. login: "rickmacd"
  3. mimetype: "text/plain"
  4. username: "rickmacd"