João Bernardo
João Bernardo

Reputation: 33

Invert matched regex pattern

I has having an hard time trying to find a title that explains what I want. I have this string

"LWSSO_COOKIE_KEY=Gkgd6113jsFPOF5vLuBBZ8l_jpP3tfqF7jSeZRWERWtrB_8XBjIiU9nMG25ywucGu5fTwCSJowux91liImgrQv6RdOdcI-BSyAxo8Ux4cnWu9fobOgc8BNsQpPhww6oZ8Sm_eBTKtmGqrhUZGE7wTJt_cpAxB0tNdDIthoZN1tpH7ZuoLcs0s6171HVfnWlKDj2dmOIw5OKU_fDtX-3YURZMuXpFeDUgAab41VgOgp3n2Z2LAWzqzfCmJ3_GzdyeViBkWqz5Ouc0Cwc4WPYtsjjq8miRb86eQe_p_oHq58U.;Path=/;HTTPOnly"

And I can use regex to select the cookie:

Gkgd6113jsFPOF5vLuBBZ8l_jpP3tfqF7jSeZRWERWtrB_8XBjIiU9nMG25ywucGu5fTwCSJowux91liImgrQv6RdOdcI-BSyAxo8Ux4cnWu9fobOgc8BNsQpPhww6oZ8Sm_eBTKtmGqrhUZGE7wTJt_cpAxB0tNdDIthoZN1tpH7ZuoLcs0s6171HVfnWlKDj2dmOIw5OKU_fDtX-3YURZMuXpFeDUgAab41VgOgp3n2Z2LAWzqzfCmJ3_GzdyeViBkWqz5Ouc0Cwc4WPYtsjjq8miRb86eQe_p_oHq58U.

But I want to select the inverse, meaning:

"LWSSO_COOKIE_KEY= ;Path=/;HTTPOnly"

This is my regex:

\w+-\w+-\w+.

I've google it but i cant seem to find any solution.

Upvotes: 0

Views: 55

Answers (1)

MonkeyZeus
MonkeyZeus

Reputation: 20737

You can use this to get everything before the cookie and everything afterwards:

"LWSSO_COOKIE_KEY=|;Path=\/;.*?"

https://regex101.com/r/l26ey3/1

Upvotes: 2

Related Questions