I am trying to validate user input which is only commas. I would like to do this with RegEx, but cannot find the correct expression.
It should check the following lines (and more):
1
12
123
1,234
12,345
123,456
and invalidate the following lines (and more crazy):
1,1
1,12
12,1
12,12
123,1
123,1
Any help would be greatly appreciated.
Here is what I have tried so far (EDIT: which do not work), as well as a few options →
^(((\d{1,3},)*\d{3})|(\d{1,3}))$
^(\d{1,3}[,])*\d{3}|\d{1,3}$
source
share