perl regex groups

Posted by Aaron Moodie on Stack Overflow See other posts from Stack Overflow or by Aaron Moodie
Published on 2010-04-19T12:40:13Z Indexed on 2010/04/19 12:43 UTC
Read the original article Hit count: 556

Filed under:
|
|

I've currenly trying to pull out dates from a file and feed them directly into an array. My regex is working, but I have 6 groups in it, all of which are being added to the array, when I only want the first one.

@dates = (@dates, ($line =~ /((0[1-9]|[12][0-9]|3[01])(\/|\-)(0[1-9]|1[0-2])(\/|\-)([0-9][0-9][0-9][0-9]|[0-9][0-9]))/g ));

is there a simple way to grab the $1 group of a perl regex?

my output is looking like this:

13/04/2009, 13, /, 04, /, 2009, 14-12-09, 14, -, 12, -, 09

© Stack Overflow or respective owner

Related posts about perl

Related posts about regex