Jump to content

case-insensitive tests and lists


Innula Zenovka
 Share

You are about to reply to a thread that has been inactive for 4757 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

What's the best way of testing

 

list source;
string test;
	if(~llListFindList(source,[test])){
		//test is in the list
	}

 without needing to worry about inconsistent upper- and lower-case letters (which drove me almost to tears yesterday before I realised that was why things weren't working right)?

So far I've come up with

 

	if(~llSubStringIndex((llToLower((string)source),llToLower(test))){

	} 

but I'm wondering if there is a better way.   There usually is.

 

 

 

Link to comment
Share on other sites

What I do is only a variation of what you are doing....  when I load my list, if I know I have to do some comparisons on certain entries, I try to force the entry in the list to be lower case using llToLower.  Then, I usually will compare with a hardcoded lowercase string.  Essentially, the reverse of what you are doing.  Also, I will do an extra step of removing whitespace from the beginning and end of the word before I put it into the list.

Link to comment
Share on other sites

well if you just need a generic find and not an index returned, what you're doing isn't bad, although you may want to use llDumpString2List with an unlikely seperator instead of (string)casts that may crossmatch 2 entries... \t and \n work good for name data... other than that... yeah, that's about as good as you can get for case insensitive.

although depending on the data, you could instead populate the list with lowercased version, and test with a lower cased version.... saving you a little on runtime load, but not so good if you need the stored data to be mixed case.

ETA:
the second sentence was covered by andromeda, sorry for duplication

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4757 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...