There's more than one way to do things | |
PerlMonks |
Re: appending to end of stringby KPeter0314 (Deacon) |
on Jun 25, 2003 at 22:06 UTC ( [id://269036]=note: print w/replies, xml ) | Need Help?? |
What you probably want is something like s/copyright.*$/$&, 2005/g. I would really try to narrow the search string down some more though.
Since you have "copyright*" as the match string, you are matching copyright or copyrightttt or copyrightttttt, but not "copyright 2003-2004" so the operator you are doing just leaves the rest of the string alone and only works with the part that matches. That is why you get the doubling up of 2003-2004. If you want to match "copyright 2003-2004" or basically copyright-to-the-end-of-the-line, then use "copyright.*$" to get it all. If not, then build a match that includes the numbers too. The dot-star bit is bad and should be eliminated. You should look at your data and build a better match. See Death to Dot Star! for more. Some of my details on the exact matching might be a little off, I'm still just a learner on regex's too.
-Kurt Update: ++demerphq for an even better explanation.
In Section
Seekers of Perl Wisdom
|
|