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.