Query multiple TOKENS?  || Please advise!
- 
 I have a search function finding all files with this token. "kick". What I'd like to do is enter multiple tokens, for instance, if it may be "KICK", "Kick", "kick", "kick", "Bass Drum", "bassdrum" etc.... Please advise!   
- 
 @Chazrox 
 If you have the same word with different spellings(KICK, Kick...), you could adjust the letters before searching. So, all letters lowercase (String.toLowerCase()) or all letters uppercase (String.toUpperCase()).This makes the original spelling irrelevant, and you only have to worry about one case. 
- 
 @Oli-Ullmann Thanks. What if I want the user to be able to type "kick" but the search results return any variations of the spelling? How do I check for multiple tokens at once? I dont know how I would do that. I can check for one spelling but multiple at once, I havent done that one yet. What im workin with now: local token1 = "kick"; //local token1 = ["KICK", "Kick", "kick", "kck", "BASS DRUM", "Bass Drum", "bass drum"]; if (token1 == "") { Console.print("No token1 entered."); return; } local txt; Console.print("Searching in: " + rootFolder.toString(1)); Console.print("Total files to check: " + allFiles.length); ComboBox1.set("items", ""); for (i = 0; i < allFiles.length; i++) { local f = allFiles[i]; local pathNOW = f.toString(0); if (pathNOW.indexOf(token1) != -1) { FoundFiles.push(f); Console.print("MATCH (name/path): " + pathNOW); } }
- 
 @Chazrox said in Query multiple TOKENS? || Please advise!: What if I want the user to be able to type "kick" but the search results return any variations of the spelling? I'm not sure what you mean. As I said, you can convert the word, e.g., Kick, to lowercase letters only before searching using String.toLowerCase(). Then you only need to search for “kick” and all variants (KICK, Kick, KiCk, etc.) will still be displayed.If you want to see all results that contain “kick” (e.g., kick drum), you can use String.contains(). Then all results should be displayed.You can also use the functions several times in a row. So if(yourVariableName.toLowerCase().contains(“kick”) || yourVariableName.toLowerCase().contains(“drum”))should give you all results that contain ‘kick’ or “drum.” The original spelling doesn't matter, because you convert all letters to lowercase before searching. 
- 
 @Oli-Ullmann ahh, I think the || is what I was looking for. I forgot about that. Thanks! I'll try these.  
- 
 Thanks. Ended up doing this. Works: if (pathNOW.contains("KICK") || pathNOW.contains("Kick") || pathNOW.contains("kick")) { FoundFiles.push(f); Console.print("MATCH (name/path): " + pathNOW); } 
- 
 This should also work, no? if (pathNOW.toLowerCase().contains(“kick”)) { FoundFiles.push(f); Console.print("MATCH (name/path): " + pathNOW); }
- 
 @Oli-Ullmann I think I was not understanding how that works but it just clicked. Yes that should work. *forehead slap. lol. Thanks! 
- 
 @Chazrox 
 he he :-)
 No problem! :-)
- 
 @Chazrox said in Query multiple TOKENS? || Please advise!: Ended up doing this. Works: Use regex. https://docs.hise.dev/scripting/scripting-api/engine/index.html#matchesregex 
- 
 Yeah, regex is your friend here. The HISE regex seems to be missing a lot of features but you can still condense it down a bit like this: const kickPattern = "kick|kck|kk|bd|bassdrum|bass\sdrum|bassd"; const snarePattern = "snare|snar|snr|sn"; const hatPattern = "hat|hh|clh|cl|oph|op"; inline function stringMatchesPattern(str, pattern) { return Engine.matchesRegex(str.toLowerCase(), pattern); } Console.print(stringMatchesPattern("Kick".toLowerCase(), kickPattern)); Console.print(stringMatchesPattern("Kck".toLowerCase(), kickPattern)); Console.print(stringMatchesPattern("Kk".toLowerCase(), kickPattern)); Console.print(stringMatchesPattern("kick".toLowerCase(), kickPattern)); Console.print(stringMatchesPattern("kk".toLowerCase(), kickPattern)); Console.print(stringMatchesPattern("BD".toLowerCase(), kickPattern)); Console.print(stringMatchesPattern("Bd".toLowerCase(), kickPattern)); Console.print(stringMatchesPattern("bd".toLowerCase(), kickPattern)); Console.print(stringMatchesPattern("BassDrum".toLowerCase(), kickPattern)); Console.print(stringMatchesPattern("Kick".toLowerCase(), kickPattern)); Console.print(stringMatchesPattern("Kick".toLowerCase(), kickPattern)); Console.print(stringMatchesPattern("Snare".toLowerCase(), snarePattern)); Console.print(stringMatchesPattern("Snr".toLowerCase(), snarePattern)); Console.print(stringMatchesPattern("Hat".toLowerCase(), hatPattern)); Console.print(stringMatchesPattern("Clh".toLowerCase(), hatPattern));If some of the usual regex tools worked, we could have shorter patterns like this: const kickPattern = "ki?c?k|b(ass)?\s?d(rum)?"Although the longer one might be easier to read and understand I guess. 



