Re: Returning substring of regex match



On Jun 4, 8:31 am, Taras_96 <taras...@xxxxxxxxx> wrote:
Say you want a list of the days in the dates for some input
with some defined prefix:

eg: Give me the days of all dates that are prefixed with the
word DATE

DATE22/5/07
1/5/07
DATE25/5/07
DATENO 26/5/07

Would return 22 and 25, but not 1 or 26.

Is this what you're looking for?

#!/usr/bin/perl
use strict;
use warnings;
while (<DATA>) {
print "$1\n" if m!DATE(\d+)/\d+/\d+$!;
}
__DATA__
DATE22/5/07
1/5/07
DATE25/5/07
DATENO 26/5/07


Take a look at
perldoc perlretut
perldoc perlre
perldoc perlreref

Paul Lalli

.