hi,

suppose i have a string that contains n number of date patterns in the
string.
"2011/05/25 07:24:58 -0700 PDT   2011/04/28 XXXXXXXXXXXX 2023/23/45"

how can i extract all such patterns.

On Wed, May 25, 2011 at 10:08 PM, Rob Dixon <rob.di...@gmx.com> wrote:

> On 25/05/2011 15:39, Irfan Sayed wrote:
> > hi,
> >
> > i have string like this
> > "2011/05/25 07:24:58 -0700 PDT"  i need to match "2011/05/25"
> > i wrote reg ex like this: ^\d\d\d\d//\d\d/\d\d$ but it is not working
> >
> > code is like this
> >
> >
> > $lin = "2011/05/25 07:24:58 -0700 PDT";
> > $lin =~ m/^\d\d\d\d//\d\d/\d\d$/;
> > print "$lin\n";
> >
> > plz suggest
>
> Please always write your code with 'strict' and 'warnings' in place,
> especially before seeking help elsewhere. This program
>
> use strict;
> use warnings;
>
> my $lin = "2011/05/25 07:24:58 -0700 PDT";
> $lin =~ m/^\d\d\d\d//\d\d/\d\d$/;
>
> produces the following errors:
>
> Backslash found where operator expected at E:\Perl\source\ps.pl line 5,
> near "d\"
> Backslash found where operator expected at E:\Perl\source\ps.pl line 5,
> near "d\"
> syntax error at E:\Perl\source\ps.pl line 5, near "d\"
> Execution of E:\Perl\source\ps.pl aborted due to compilation errors.
>
> And tells you immediately that there is something wrong with your regex.
>
> Cheers,
>
> Rob
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>

Reply via email to