View Full Version : Struggling with Case Sensitivity
JellyFire 05-04-2008, 02:00 PM Hey guys/girls,
I need to search a folder for other folders containing a certain word, the word is the same everytime, but CAN (but shouldn't) change case, which is a bit annoying!
So something like:
string $list[] = `getFileList -folder $path -filespec "*name*"`;
but have it return a list with both "name" and "NAME"
I could do it twice and append the array, but is there another way to get what I want?
Thanks for any help!
Christian
|
|
sj_bee
05-04-2008, 06:06 PM
You could get the file name once and then use toupper and tolower to check for both upper and lower case situations
Along those lines you would do something like this:
string $list[] = `getFileList -folder $path`;
for ($item in $list) {
//convert the filename to lower case
string $lowerItem = tolower($item);
//check if the lowercase filespec matches the lowercase filename
if (gmatch $fileSpec $lowerItem) {
//do something with $item
}
}
JellyFire
05-09-2008, 09:00 AM
Thanks guys, I have this working with something similar. I was just wondering if you could search for a string ignoring case sensitivity, so the same one line command would return both "this" and "THIS".
I guess there's not then :)
Cheers anyway.
Christian
BenBarker
05-09-2008, 07:22 PM
Just do the comparisson with the forced lower case version, but note the original filename if it passes. You can do this with the example above. Append $item to an array and keep going, then return the array when you are done.
CGTalk Moderation
05-09-2008, 07:22 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.