$_ = 'url?a=1&name=test&id=2';s/^([^&]*)(&[^&]+)(&.*)$/$1&newname=againtest$3/;print $_;
Standard input is empty
url?a=1&newname=againtest&id=2
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!