This is for testing the string $regs. The first part check it if it is according to a year format (4 digits, from 0 to 9 for each digit). The second and third part for checking either day or month (1 or 2 digits, again from 0 to 9, although you need only 1 to 12 for months and 1 to 31 for days).
Is it clear? This is based on "regular Expressions".