Help with reqrep

I’m using haproxy 1.6.x. I am having a heck of a time understanding how to use reqrep. I believe this is the only option to accomplish my goal - partially due to the haproxy version, partially due to the use case. eg. I believe I need to use brackets in the regex, which regsub doesn’t support. If I was using sed, I think one option that would work would be: sed ‘s/parameter2=[^&]*&//’ I have spent an inordinate amount of time trying to figure this out without success. I would be grateful if someone could break down the usage of reqrep for me. I’ve googled plenty, but I am clearly missing something fundamental.

Use case: I am attempting to remove a query parameter in a request made to haproxy, or worst case modify the value of the query parameter.
If a query is made to: http://host/blah?parameter1=abcd&parameter2=efgh&parameter3=ijkl
I would like haproxy to modify it to remove parameter2: http://host/blah?parameter1=abcd&parameter3=ijkl
Alternatively parameters2 could have it’s value to something I define. The solution must allow for new parameters to be included. All of the other parameters must be preserved and I do know what they are ahead of time.

I could also make due with: http://host/blah?parameter1=abcd&parameter2=somethingnew&parameter3=ijkl

Any help you could offer would be very appreciated!

Hi,
I wouldn’t involve regsub here, this should cover your use case:
reqrep (.*)(&|\?)p2=[^&]+&(.*) \1\2\3
\1 gets the method and uri up to your param, \2 gets either ? or & depending on param order, and \3 gets the remaining of the line.
I would still recommend you update to 2.0 and use http-request replace-uri instead of reqrep.

Thank you very much for your help and explanation. I really appreciate it!