为了账号安全,请及时绑定邮箱和手机立即绑定

正则贪婪模式,怎么搞清楚?总是一下子把后面的都给匹配上了

正则贪婪模式,怎么搞清楚?总是一下子把后面的都给匹配上了

凤凰求蛊 2019-03-13 18:15:32
t=edc9624908fac06b969fc8b3454d4d75; cna=rz39DUM8tSgCAXLjRlx1SJH8; l=Ah8fI61XmUXv5/-aXUJ9Fiy3732phHMm; lzstat_uv=7058553501377199257|1774292@1774054; cookie2=fa6653f49ed68b38b469988a4f1a2ac7; _tb_token_=obU42Ba54Lp; v=0; cookie32=d2874877ef98c1c142fc1ddff656fb50; cookie31=MTA5NzY3MjEsa2lzdGVhcixqc3djQDE2My5jb20sbnVsbA%3D%3D; alimamapwag=TW96aWxsYS80LjAgKGNvbXBhdGlibGU7IE1TSUUgNy4wOyBXaW5kb3dzIE5UIDYuMjsgV09XNjQ7IFRyaWRlbnQvNy4wOyAuTkVUNC4wQzsgLk5FVDQuMEU7IC5ORVQgQ0xSIDIuMC41MDcyNzsgLk5FVCBDTFIgMy4wLjMwNzI5OyAuTkVUIENMUiAzLjUuMzA3Mjkp; login=W5iHLLyFOGW7aA%3D%3D; alimamapw=DggWRANZRTAHBVcABwAEBQRbUFZcAgVeB1oEBwAHU1AEA1INVAUAUg%3D%3D上面这个COOKIES 用正则匹配_tb_token_=obU42Ba54Lp;这个值,用这个表达式直接把后面一长串都给匹配上了,然后变成这样了_tb_token_=obU42Ba54Lp; v=0; cookie32=d2874877ef98c1c142fc1ddff656fb50; cookie31=MTA5NzY3MjEsa2lzdGVhcixqc3djQDE2My5jb20sbnVsbA%3D%3D; alimamapwag=TW96aWxsYS80LjAgKGNvbXBhdGlibGU7IE1TSUUgNy4wOyBXaW5kb3dzIE5UIDYuMjsgV09XNjQ7IFRyaWRlbnQvNy4wOyAuTkVUNC4wQzsgLk5FVDQuMEU7IC5ORVQgQ0xSIDIuMC41MDcyNzsgLk5FVCBDTFIgMy4wLjMwNzI5OyAuTkVUIENMUiAzLjUuMzA3Mjkp; login=W5iHLLyFOGW7aA%3D%3D; alimamapw=DggWRANZRTAHBVcABwAEBQRbUFZcAgVeB1oEBwAHU1AEA1INVAUAUg%3D%3D我知道用\W可以搞定,但是我非要用.*的话应该怎么弄?就匹配到第一个;?
查看完整描述

2 回答

?
慕码人2483693

TA贡献1860条经验 获得超9个赞


out=re.search("_tb_token_=(.*?);",token).groups()[0]

print(out)


查看完整回答
反对 回复 2019-04-17
  • 2 回答
  • 0 关注
  • 420 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信