Both suggestions propose to check for a space to follow the date, but that will work well in this example, but will fail for dates that are located at the end of the line.
As you posted your data explicitely, that won't be a problem, but maybe looking at the criterium a bit more defensive, you can also say: match a date *not* followed by any of -, digit, letter or underscore (identifier characters).
my @lines = grep { m/ \b (?: 0[1-9] | 1[0-2] ) - (?: 0[1-9] | [12][0-9 +] | 3[01] ) - [0-9]{4} ) (?! [-\w] ) /x } @data;
And your input data is horrific: MM-DD-YYYY ... YYYY/MM/DD. How on earth does someone come up with a mixed format like that? (/me is all for a global ban on M/D/Y and Y/D/M format)
In reply to Re: grep only lines having matched pattern
by Tux
in thread grep only lines having matched pattern
by noviceuser
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |