Reputation: 35
I am trying to achieve scenario like that
2014-000000-01
[[0-9]{0,3}\-[0-9]{0,5}\-[0-9]{0,1}]
I want restrict user not to insert more or less than 4 characters before dash After dash he can enter 6 character of less than six and after second dash he can not insert less than or greater than two.
Can any one point out how can i achieve it.
Thanks in Advance
Upvotes: 0
Views: 71
Reputation: 5261
Depending on the context, you may need to use begin and end anchors. If it's in a validator, sometimes it's implied to match the entire string. If not, it would still match, even if there were more than 4 digits at the beginning, for instance.
Here it is with anchors:
^\d{4}-\d{1,6}-\d{2}$
Upvotes: 1