Forum Moderators: phranque
While it works just fine, my code seems longer than it needs to be.
I'm sure it doesn't make it any less efficient, but the long lines of code does make it a pain when trying to edit them.
Can these be made shorter?
My notes are on the left side of the colon, my modrewrite is on the right.
Year (2000+): (2[0-9]{3})
Month (01-12): (0[1-9]{1}¦1[0-2]{1})
Day (01-31): (0[1-9]{1}¦[12]{1}[0-9]{1}¦3[0-1]{1})
Thanks
In groups, you can specify either ranges or alternates, so a group of [0-1] is equivalent to a group of [01]. A group of [0-2] is equivalent to a group of [012]. It is actually faster to use the latter non-range notation until the range size exceeds 3.
So you can rewrite, for example, your last pattern as:
(0[1-9]¦[12][0-9]¦3[01])