John Peacock <[EMAIL PROTECTED]> wrote:

> When I made a very simple attempt at this back in January, I limited myself to
> the most basic format:
>
>      if ( @date =
>          ( $val =~ /(\d\d\d\d)   # year with century
>                      -?          # possible hyphen
>                     (\d\d)       # month
>                     -?           # possible hyphen
>                     (\d\d)       # day
>                     (?:T         # time is optional
>                       (\d\d)     # hours
>                       :(\d\d)    # minutes
>                       (?:        # seconds are optional
>                        :(\d\d)   # seconds
>                       )?
>                     )?
>                    /x

That's too general, actually.  There must be a hyphen either both
places or none of them.  The above matches "2003-0619" and
"200306-19".  :-)

Something like this should do the trick (untested)

                    (\d\d\d\d)   # year with century
                    (-?)         # possible hyphen
                    (\d\d)       # month
                    \2           # possible hyphen
                    (\d\d)       # day
                    ...          ...

Peter

-- 
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;

Reply via email to