I need restict values for input tag by next values :
1
1,2,3
!2,!3
[1-2]
[1-4],[3-5]
![1-4],![3-5]
1,2,3,[1-4],[3-5]
![1-4],![3-5],1,2,!7
1,2,3..7 are just examples, it may be any digits
My pattern is :
<input type="text" pattern="(\d*|[\d\-\d,]*|[\!\d]*|[|\[\d-\d\],]*|[\!\[\d\-\d\],]*)"/>
But this is also acceptable:
!!!!!![10-121,444--------,,,,,!!!!----------------,----------]
>Solution :
It looks like you’re looking for a sequence of items that are either a number or a range, both possibly preceded by an exclamation mark.
A single item can be represented as follows :
!?(\d|\[\d-\d\])
A sequence of such items is the item, followed by any number of a comma and another occurence of the item, which can be represented as follows :
!?(\d|\[\d-\d\])(,!?(\d|\[\d-\d\]))*
You can try it here.