in reply to Re: Replace part of a regex match
in thread Replace part of a regex match

kyle, could the following change to the your regex be a little closer to what the OP sought...
$u =~ s/(.*\|{5}).*(\|.*)/${1}976$2/;

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^3: Replace part of a regex match
by AnomalousMonk (Archbishop) on Dec 24, 2008 at 06:43 UTC
    The regex expression .*\|{5} matches anything followed by exactly five '|' characters in a row, which is not what is present in the example of the OP.

    A regex something like the following might be better (although it is still a bit awkward):

    >perl -wMstrict -le "my $u = 'http://foo.bar.de/?baz|2.0|323|91793|1|277|fee=_fie'; print $u; $u =~ s{ \A ((?: [^|]* \|){5}) \d+ (\|.*) \z }{${1}976$2}xms; print $u; " http://foo.bar.de/?baz|2.0|323|91793|1|277|fee=_fie http://foo.bar.de/?baz|2.0|323|91793|1|976|fee=_fie