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

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