egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

make lsearch case insensitive

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
darton
Op


Joined: 21 Jan 2006
Posts: 155

PostPosted: Thu Aug 10, 2006 10:27 am    Post subject: make lsearch case insensitive Reply with quote

Hello!
If I use the command "lsearch" to look for the word "test" in a textfile, there is a difference between test and Test. But I want that they are equal. Unfortunately the function -nocase is only available from TCL 8.5. As I am using a windrop, compiling is not that easy. So is there another possibility to make the lsearch command case insensitive?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Aug 10, 2006 10:35 am    Post subject: Reply with quote

You could always do the ugly hack; making sure list is always lowercase (string tolower if your friend here).
It's not a pretty solution, but it usually does the trick...
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Thu Aug 10, 2006 7:41 pm    Post subject: Reply with quote

lsearch has a -regexp option, and regexp has options for case-insensitive matching, so perhaps play around with that a bit..
Back to top
View user's profile Send private message
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Fri Aug 11, 2006 12:14 am    Post subject: Reply with quote

Have you tried using the following?
Code:
lsearch -exact -nocase { list } pattern
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Aug 11, 2006 4:24 am    Post subject: Reply with quote

[lsearch] has -nocase switch in Tcl 8.5 only
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Fri Aug 11, 2006 9:35 am    Post subject: Reply with quote

you may have to settle with converting to all lowercase before searching

Code:
set list [string tolower $variable]
lsearch $variable text
Back to top
View user's profile Send private message
darton
Op


Joined: 21 Jan 2006
Posts: 155

PostPosted: Fri Aug 11, 2006 10:57 am    Post subject: Reply with quote

Yes nml375 alread said that. It's a little bit circumstantial but it works.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber