case 1:
IN: example.com?p1=val1&p2=val2&p3=val3
OUT: example2.com?p1=val1&p2=val2&p3=val3&p4=val4
-- p4=val4 was added to the end, the rest of the parameters were preserved
case 2:
IN: example.com?p1=val1&p4=badvalue
OUT: example2.com?p1=val1&p4=goodvalue
-- the value of p4 was changed, so we need to scan for the existence of the parameter p4 and change its value to a constant ("goodvalue")
This isn't for Apache .. it's for the SQUIRM rewrite_program called by Squid 2.6. Just need the pure regex ... thank you