in reply to Replace part of a regex match

It seems to me that you want to replace the penultimate group that's separated with vertical bars with something else. In that case, I'd use
s/\|[^|]*\|([^|]*)$/|976|$1/;