用pytho写一个使用re正则表达式提取相应字符串中特定子串

各位大佬求帮助
string1="   180 TCP 192.168.0.131:47570 ->  117.18.237.29:80 [proto: 7/HTTP][cat: Web/5][1 pkts/74 bytes -> 0 pkts/0 bytes][Goodput ratio: 0/0][< 1 sec][Plen Bins: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
使用re.match提取180,tcp,源ip和端口,目的ip和端口,proto:的内容

#笔试题目#
全部评论
re.findall(r" ?(\d+) +(.*?) +(.*?) +-> +(.*?) +\[proto:(.*?)\].*", s)
点赞 回复
分享
发布于 2020-09-26 15:04

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务