Use .indexOf instead of regex to stop duplicates in palette search

Can't see any performance issues this way, and it is more obvious what's going on.