我有一个 http 标头响应示例:
HTTP/2 200 content-type: application/json; charset=utf-8vary: Cookie, Accept-Language, Accept-Encoding content-language: en date: Wed, 08 Jul 2020 21:20:44 GMT content-encoding: gzip set-cookie: ds_user=usadaida521; Domain=.instagram.com; expires=Tue, 06-Oct-2020 21:20:44 GMT; HttpOnly; Max-Age=7776000; Path=/; Secure set-cookie: csrftoken=ev0sLTzbC4WIIk2FKvGcLLyVqgiFXD3A; Domain=.instagram.com; expires=Wed, 07-Jul-2021 21:20:44 GMT; Max-Age=31449600; Path=/; Secure set-cookie: rur=FTW; Domain=.instagram.com; HttpOnly; Path=/; Secure set-cookie: ds_user_id=35321243349; Domain=.instagram.com; expires=Tue, 06-Oct-2020 21:20:44 GMT; Max-Age=7776000; Path=/; Secure set-cookie: sessionid=35321243349%3AP3jlNxxuIVGoJx%3A24; Domain=.instagram.com; expires=Thu, 08-Jul-2021 21:20:44 GMT; HttpOnly; Max-Age=31536000; Path=/; Secure content-length: 685alt-svc: h3-29=":443"; ma=3600,h3-27=":443"; ma=3600
我需要得到的是:
ds_user=usadaida521; Domain=.instagram.com; expires=Tue, 06-Oct-2020 21:20:44 GMT; HttpOnly; Max-Age=7776000; Path=/; Secure;csrftoken=ev0sLTzbC4WIIk2FKvGcLLyVqgiFXD3A; Domain=.instagram.com; expires=Wed, 07-Jul-2021 21:20:44 GMT; Max-Age=31449600; Path=/; Secure;rur=FTW; Domain=.instagram.com; HttpOnly; Path=/; Secure;ds_user_id=35321243349; Domain=.instagram.com; expires=Tue, 06-Oct-2020 21:20:44 GMT; Max-Age=7776000; Path=/; Secure;sessionid=35321243349%3AP3jlNxxuIVGoJx%3A24; Domain=.instagram.com; expires=Thu, 08-Jul-2021 21:20:44 GMT; HttpOnly; Max-Age=31536000; Path=/; Secure
我使用这个正则表达式:
/^set-cookie:\s*([^;]*)/mi
但我得到:
ds_user=usadaida521;csrftoken=zL2U5EvMG61MNnPaQUGjpK2qklE5uBQ2;rur=FTW;ds_user_id=35321243349;sessionid=35321243349%3ALFbjFj8eRIkr2u%3A21
你能帮我吗?谢谢你
30秒到达战场