| View previous topic :: View next topic |
| Author |
Message |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Thu Aug 10, 2006 10:27 am Post subject: make lsearch case insensitive |
|
|
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 |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Aug 10, 2006 10:35 am Post subject: |
|
|
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 |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Thu Aug 10, 2006 7:41 pm Post subject: |
|
|
| lsearch has a -regexp option, and regexp has options for case-insensitive matching, so perhaps play around with that a bit.. |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Fri Aug 11, 2006 12:14 am Post subject: |
|
|
Have you tried using the following?
| Code: | | lsearch -exact -nocase { list } pattern |
|
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Fri Aug 11, 2006 4:24 am Post subject: |
|
|
[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 |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Fri Aug 11, 2006 9:35 am Post subject: |
|
|
you may have to settle with converting to all lowercase before searching
| Code: | set list [string tolower $variable]
lsearch $variable text |
|
|
| Back to top |
|
 |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Fri Aug 11, 2006 10:57 am Post subject: |
|
|
| Yes nml375 alread said that. It's a little bit circumstantial but it works. |
|
| Back to top |
|
 |
|