0

I am trying to use a "RequestHeader edit" directive to manipulate the "Cookie" header and only keep a specific set of cookies from that header.

RequestHeader edit Cookie "PATTERN TO REMOVE ALL COOKIES DESPITE OF .." ""

Incoming

someCookie=someValue; anotherCookie=yada61; cookieToKeep-1=myValue; cookieToKeep-2=myValue2; lastCookie=yada1

To keep

cookieToKeep-1=myValue; cookieToKeep-2=myValue2;

Goal is to remove all cookies but any cookie that starts with "cookieToKeep-".

I found that Pattern (CookieToKeep-\d=(([\w]*;)|[^\s]+)) gives me all matches for the cookies I need, but I need the negative of this pattern.

Juan Serrats
  • 1,358
  • 5
  • 24
  • 30
Felix
  • 3
  • 1

1 Answers1

0

Try negative lookahead (for each cookie name): ^(?!cookieToKeep-).*.

Valdi_Bo
  • 30,023
  • 4
  • 23
  • 41