Use the backlink and negative view:
^(Dog|Cat|Bird|Mouse)(, (?!\1)(Dog|Cat|Bird|Mouse))*$
EDIT . This will not work with cases like "Cat, Dog, Dog" ... You will need to create a hybrid solution for such cases - I do not believe there is one regular expression that can handle this.
Here is another method. You need to check two things, firstly, that it matches this:
(?:(?:^|, )(Dog|Cat|Bird|Mouse))+$
(This is a slightly shorter version of the original regex)
, :
(Dog|Cat|Bird|Mouse).+?\1
.
var valid = string.match( /(?:(?:^|, )(Dog|Cat|Bird|Mouse))+$/ ) &&
!string.match( /(Dog|Cat|Bird|Mouse).+?\1/ );