This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Help for those learning Tcl or writing their own scripts.
darton
Op
Posts: 155 Joined: Sat Jan 21, 2006 11:03 am
Post
by darton » Thu Aug 10, 2006 10:27 am
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?
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Thu Aug 10, 2006 10:35 am
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
rosc2112
Revered One
Posts: 1454 Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania
Post
by rosc2112 » Thu Aug 10, 2006 7:41 pm
lsearch has a -regexp option, and regexp has options for case-insensitive matching, so perhaps play around with that a bit..
DragnLord
Owner
Posts: 711 Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA
Post
by DragnLord » Fri Aug 11, 2006 12:14 am
Have you tried using the following?
Code: Select all
lsearch -exact -nocase { list } pattern
demond
Revered One
Posts: 3073 Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:
Post
by demond » Fri Aug 11, 2006 4:24 am
[lsearch] has -nocase switch in Tcl 8.5 only
connection, sharing, dcc problems? click
<here>
before asking for scripting help, read
<this>
use
DragnLord
Owner
Posts: 711 Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA
Post
by DragnLord » Fri Aug 11, 2006 9:35 am
you may have to settle with converting to all lowercase before searching
Code: Select all
set list [string tolower $variable]
lsearch $variable text
darton
Op
Posts: 155 Joined: Sat Jan 21, 2006 11:03 am
Post
by darton » Fri Aug 11, 2006 10:57 am
Yes nml375 alread said that. It's a little bit circumstantial but it works.