I'm looking at the expected answers and I'm not sure that your regular expression is correct. By looking for /ad/i, you are looking for a and d right next to each other. If the parameter you are sending is "a,d", then you will not get a match. If they are only coming in that order, then you could change your regular expression to /a,d/. If not then