Regex pattern for a number within a number -
Can someone think of a better way of writing it? It works, but it's a bit ugly.
The input data looks like this: 125100001
The first two numbers are years, the numbers are the next two weeks, and the last 5 are serials. I want to make sure that the number of weeks is not more than 52 for one option. Originally to take advantage of just $ error area :)
Here it is:
^ \ d \ d (0 [0-9] | 1 [0] -9]] | 2 [0-9] | 3 [0-9] | 4 [0-9] | 5 [0-2]) {1} \ d {5} $
For only part of the week:
[0-4] \ d | 5 [0- 2]
then the entire regex will be:
Comments
Post a Comment