>>>>> "Stephan" == Stephan Gross <[EMAIL PROTECTED]> writes:
Stephan> I'm matching a SQL date like this: Stephan> $ftime =~ /(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)/; Stephan> If $ftime is "2001-05-13 11:53:00", then $1 is "2001", $2 is "05", etc. Stephan> However, I also want to match if the user types in a partial string. For Stephan> example, if $ftime is "2001-12-18", I want $1, $2 and $3 to be "2001", "12" Stephan> and "18" but $4 to be null. In reality, my regex fails entirely and $1 is Stephan> null. Stephan> How can I get $1, $2, $3, $4, $5 and $6 to contain as many matches as my Stephan> input string has? Do I have to use 6 separate regexes? if (my @matches = grep defined, $ftime =~ /(\d+)(?:-(\d+)(?:-(\d+)(?:\s+(\d+)(?::(\d+)(?::(\d+))?)?)?)?)?/) { ... $matches[0]..$matches[6] are now set as many as are defined... } Your first example was broken in that you weren't testing the overall match, and if that had failed, you would have gotten the *previous* match. Bad News. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]