I am attempting to write a regex to validate user input (asp.net, c#) which has the following conditions:
- single digits within a range of 1 - 6
- comma separated, but list should not begin or end with a comma
- digits cannot be repeated
- digits should be in ascending order
For example:
- 1,2,3,4,5,6 - valid
- 2,5,6 - valid
- 4 - valid
- 2,5,6, - invalid
- 3,6,5 - invalid
- 2,2,5,6 - invalid
So far I've got:
^((1,)?(2,)?(3,)?(4,)?(5,)?(6)?)$
The issue with this is the numbers 1-5 have to be followed by a comma which, if they are the only number being input, is not correct.