in reply to negative look-ahead is ignored

Although the exact answer to the question has been given, I feel there is a deeper answer to this. I would advise searching for what you DO expect rather than picking on what might be insufficient examples of what you don't. In this case, that isn't clear in the OP. But if the data is supposed to terminate at this point, it is better to match on the terminator, e.g.
/^\d{4}\-\d{2}$/ or die; # match on end of string after \d{2}, or ... /^\d{4}\-\d{2}\s+/ or die; # match on whitespace delimiter # etc.

-M

Free your mind

Replies are listed 'Best First'.
Re^2: negative look-ahead is ignored
by jeanluca (Deacon) on Feb 19, 2007 at 16:56 UTC
    I always try to keep my questions as short as possible!
    So they often do not describing the true issue
    Anyway, I get your point, but in my case, in which I've written a 'generic date parser/converter' I don't really want to use ^ and $, it would limit the number of possible date formats, for example
    "2005-031" " 2005-31" "2005031 " "|2005-031 12:11:22| " "Some time ago 1776-07-04 ....."
    And I'm not even started to scratch the surface of what my 'generic date parser/converter' can do more :)

    Thnx
    LuCa
      In that case I would be inclined to maintain a list of regexps - one for each allowable format - rather than (I predict) torturing one into handling successive new requirements until it finally dies in an agony of unmaintainability. I might even put them in a configuration file rather than code for easy update in production environments, load and chop them them into an array and then try them out successively on the data until a match is found or the possible formats exhausted.

      -M

      Free your mind

      You probably already know about Date::Manip. It has a function ParseDateString that should do some of what you want.
        I don't know Date::Manip that well, but I think that the reason I once started with a date parser was because of problems related to epoch seconds and milliseconds.
        But I guess I can improve my module if I would use Date::Manip!
        Thanks for the suggestion!

        LuCa