Skip to content
Tcl Source Code View Ticket
Login

View Ticket

regexp a{0} provides incorrect results

Closed / Invalid1102326fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2005-01-14 13:26:05
set pat1 {a{0}}
set pat2 {a{1}}
set pat3 {a{0,1}}

set string "xyz"
foreach i [list $pat1 $pat2 $pat3] {
        puts "Does $string match $i? [expr [regexp --
$i $string] ? yes : no]"
}

set string "abc"
foreach i [list $pat1 $pat2 $pat3] {
        puts "Does $string match $i? [expr [regexp --
$i $string] ? yes : no]"
}

The above code was expected to report that in the first
loop, a yes, then two nos and in the second loop, one
no then two yeses.

On sparc solaris with 8.4.8 (and 8.5a2), I get this
instead:
 $ ./tclsh8.4 /tmp/testre          
Does xyz match a{0}? yes
Does xyz match a{1}? no
Does xyz match a{0,1}? yes
Does abc match a{0}? yes
Does abc match a{1}? yes
Does abc match a{0,1}? yes
lvirdenplain2005-01-14 21:31:10
Logged In: YES 
user_id=15949

Doesn't work for me even using tclkits and ActiveTcl's
tclsh, so it isn't  the build of the software .  I don't
have a Solaris 9 machine to try things on.  Note that the
concept of the report is conceptually the same as a
discussion thread currently going on comp.lang.tcl , where
someone else from another platform and site reports similar
problems.
dgp Closed ticket [1102326fff]. [History diff]2005-01-15 03:35:37
dgpplain2005-01-15 03:35:38
Logged In: YES 
user_id=80530

Those results look correct to me.

Keep in mind that the empty
string is a substring of every
string, and the patterns a{0}
and a{0,1} match the empty string.
dgp Ticket [1102326fff]: 2 changes [History diff]2005-01-15 03:35:39
Log in (anonymous is fine) to add a comment.