in reply to Matching date range with pure regex
I might be missing part of your question, but this appears (applying the KISS principle) to do what you ask:
#! /usr/bin/perl -wl use strict; while( <DATA> ) { chomp; print "$_ ", /^(19[5-9]\d|20([0-4]\d|50))$/ ? 'ok' : 'nok'; } __DATA__ 1949 1950 1951 1999 2000 2001 2010 2049 2050 2051 2102 22102 19534 19080 20010
|
|---|