in reply to Matching date range with pure regex

use strict; while (<DATA>) { chomp; print "$_ is ", /^(?:19|20) (?: (?:(?<=19)[5-9]|(?<=20)[0-4])[0-9] | 50)$ /x ? "Ok" : "not ok", "\n" } __DATA__ 1050 1950 2050 2054 1980 2004 3100

Updated: Added the trailing '$' in the regex to limit the length to 4 characters. Thanks MCS for pointing that out. :-)