請問下面的這個程式,我ip的第一位提取出來都只有一位數,請問哪位大大可以幫忙解答?
import re
str1 = """TCP source 12.168.189.167:32806 destination 1.78.5.128:65247, idle 0:00:00, bytes 74, flags UIO
TCP source 192.168.189.167:80 destination 137.78.5.128:65233, idle 0:00:03, bytes 334516, flags UIO """
print(str1)
list1 = str1.split('\n')
for x in list1:
result = re.match(
".*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5}).*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5}).*bytes\s+("
"\d+).*flags\s+(\w*)\s*", x).groups()
print(result)
結果會變成如下
('2.168.189.167', '32806', '1.78.5.128', '65247', '74', 'UIO')
('2.168.189.167', '80', '7.78.5.128', '65233', '334516', 'UIO')