简体   繁体   中英

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.

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM