MAC Address Regex
Matches MAC addresses in colon or hyphen notation.
パターン
/\b([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}\b/g
→ ビジュアライザーで開くテスト例
Devices: 00:1A:2B:3C:4D:5E and 00-1A-2B-3C-4D-5E connected.
コード例
javascript
const regex = /\b([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}\b/g;
const result = str.match(regex);python
import re
pattern = re.compile(r'\b([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}\b')
result = pattern.findall(text)go
import "regexp"
re := regexp.MustCompile(`\b([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}\b`)
result := re.FindAllString(text, -1)networkmac addresshardware