Yesterday I\'ve got a task to implement a validation on the field where user can enter the range of pages that he wants to download.
After reading some tutorials, I
You can try the regex:
^(\d+(-\d+)?)(,\d+(-\d+)?)*$
To allow white spaces between you can do:
^(\s*\d+\s*(-\s*\d+\s*)?)(,\s*\d+\s*(-\s*\d+\s*)?)*$
Rubular link