One approach might be to extend the SKIP-FAIL trick for excluding URLs to also exclude dates:
    $text =~ s{ (?: $url | $date) (*SKIP) (*FAIL) | ($digits_3_4) }{...}xmsg

Of course, this leaves you with the headache of trying to define a regex to match every possible format of date that a human bean might imagine. Here's a start, but please be aware that this code is untested and also that the  $date regex does not nearly cover every possible permutation of day-month-year ordering or the many internal separator sequences that might be used; you will have to extend this defnition as needed. (Also note that the  $yr pattern is limited to the 21st century.)

my ($month_name) = map qr{ (?<! [[:alpha:]]) (?: $_) (?! [[:alpha:]]) }xms, join q{|}, map { $_, ucfirst($_), uc($_) } map { $_, substr $_, 0, 3 } qw(january february march april may june july august september october november december) ; ;; my $month_number = qr{ (?<! \d) (?: 0? [1-9] | 1 [012]) (?! \d) }xms; ;; my $month = qr{ $month_name | $month_number }xms; ;; my $day = qr{ (?<! \d) (?: 0? [[1-9] | [12] \d | 3 [01]) (?! \d) }xms; ;; my $yr = qr{ (?<! \d) 20\d\d (?! \d) }xms; ;; my $sep = qr{ [-/] | \s+ }xms; ;; my $date = qr{ $yr $sep $month $sep $day | $month $sep $day $sep $yr | $day $sep $month $sep $yr }xms;
(This regex is 5.8.9 compatible.) The first thing you will want to do is write a Test::More script to test your  $date regex against every possible date format you've ever encountered and any others you can imagine.

BTW: You have never said if your version of Perl is 5.10 or later, so I don't even know if the SKIP-FAIL trick is possible for you. What version of Perl are you using?


Give a man a fish:  <%-{-{-{-<


In reply to Re^5: Replacing 3 and 4 digit numbers. by AnomalousMonk
in thread Replacing 3 and 4 digit numbers. by htmanning

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.