I am building an application which should accept strings only with the following formats:
- 12345 (only a number)
- 12345;23456 (two or more numbers separated by 😉
- 12345-12367 (a range of numbers separated by a -)
The java script regex should allow only the above formats & shouldn’t accept any other formats or symbols . Can anyone come up with a regex for this?
This is the RegExp that you need:
/^\d+((;\d+)*|-\d+)?$/(;\d+)*will check for multiple numbers separated by “;”-\d+will check for a range