This (?:...)means a set of non-converting brackets for grouping.
Usually, when you write (...)in a regular expression, it "captures" the matched material. When you use the non-converting version, it is not fixed.
You can get the various parts matching regex using methods in reafter the regex matches a specific string.
MAC- "00: 07: 32: 12: ac: de: ef"?
, . , :
([\dA-Fa-f]{2}(?:[:-][\dA-Fa-f]{2}){5})
; , , , .
[\dA-Fa-f]{2} (\d) A-Fa-f], {2}, , ( -), , 5 .
p = re.compile(([\dA-Fa-f]{2}(?:[:-][\dA-Fa-f]{2}){5}))
m = p.match("00:07:32:12:ac:de:ef")
if m:
m.group(1)
"00: 07: 32: 12: ac: de", ( ). , , , m.group(0) ( ). 7 , 5 6. , :
p = re.compile(^([\dA-Fa-f]{2}(?:[:-][\dA-Fa-f]{2}){5})$)
^ ; $ . 5, . 6 5 .