At 12:09 +0100 11/25/2005, Matthias Hoffmann wrote:
>how do I perform a case-insensitiv LSEARCH? I am missing a -nocase
>switch like in STRING MATCH...
It's ugly and inefficient for large lists (but probably more
efficient than -regexp):
% set l [list a Be cEe]
a Be cEe
% set p bE
bE
% lsearch [string tolower $l] [string tolower $p]
1
% set p CeE
CeE
% lsearch [string tolower $l] [string tolower $p]
2
%
Of course, if the pattern or list are known to be lowercase or
uppercase then you can leave off the tolower from that argument
and/or use toupper instead of tolower on the other.
P.S. I get an SMTP error replying directly to Matthias Hoffmann
<
M.Hoffmann@hmk....>.
--
Jeff Woods
"Errors creep into everything, and the only way to expunge them is to
have any bit of work reviewed by a few others." -- Wirt Atmar, 10-27-2001
"The great thing about Open Source software is that you can have any
color screen of death that you want." -- Gavin Scott, 08-22-2000
_______________________________________________
ActiveTcl mailing list
ActiveTcl@list...
To unsubscribe:
http://listserv.ActiveState.com/mailman/mysubs
opensubscriber is not affiliated with the authors of this message nor responsible for its content.