in reply to changing only the first two matches of a regex

I would do something like:
s/(\d+_)(.*)?(\d+_)(.*)/$1$2/;
But I'm certainly not a regex-wizard...

Jouke Visser, Perl 'Adept'

Replies are listed 'Best First'.
Re: Re: changing only the first two matches of a regex
by Masem (Monsignor) on Mar 20, 2001 at 19:18 UTC
    With what you have above, the replace should be $2$4, since you have 4 grouping operators there. Or you could just have "\d+_", or use "(?:\d+_)" as to use $1$2 as others have done later in this thread.
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain