> For example
>
> 12, 22, 3, 45, 3, 36
>
> should fail the validation since number 3 has been repeated. Is that
> even possible?
I would try vice versa approach: "If a value is present twice in a
string, that string is no good" You just change logic operator in your
code. And the regex to test wether a CSV string contains duplicate
numbers would be
(\d+)[, ]+(?:\d+, )*?\1[, \r\n]+
^ ^
|__spaces here____|
So, report if that approach works.