in reply to modifying list of numbers

my $year = 2003 s/(copyright\s+)(\d{4})(?:-\d{4})?/$1 . ($2 eq $year ? $2:"$2-$year")/ +ie;

That won't handle something like "copyright 1990, 1991" though. Nor will it handle "Copyright (C) 1990-2003".

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re: Re: modifying list of numbers
by jc23 (Acolyte) on Jul 18, 2003 at 15:47 UTC
    Hey sauoq,

    thanks for the advice. How could i modify your code to have it pick up the entire string and just append to the end of the list? I had something like :

    s/[cC]opyright*.*?$/$&,$year/g

    but that doesnt pick up in cases where there are extra words after the year such as "Copyright 1990-2002, blah blah more text here" Instead I need something that will make it "Copyright 1990-2002,2003, blah blah more text here"

    thanks much! jc

      That would be a little less complicated actually. How about something like:

      s/(copyright\s+[\d, -]*)/$1, 2003/i;
      ?

      Edit: Changed character class to use a literal space and (oops) put the hyphen in the right place: at the end.

      -sauoq
      "My two cents aren't worth a dime.";
      
        awesome. thanks!