I’ve to create a regex with this rules:
- Number are between 5-100
- Number are separated by comma (55,70,90)
- Number are unique in string
For example:
- 10,20,50 OK
- 10 ,20,50 NO (white space)
- 10,20,50, NO (final comma)
- 10,10,20 NO (unique)
Can you help me?
Although it may be possible to perform all checks with a regex, I think it’s not the right tool for the job.
I would:
^(?:[0-9]+,)*[0-9]+$split(',', $input)to turn into array