bitcanon / mactool

Simplify MAC Address tasks using this command-line application written in Go.
MIT License
1 stars 0 forks source link

Improve regex matcher #8

Closed bitcanon closed 1 year ago

bitcanon commented 1 year ago

Try to improve the matching of MAC addresses. The current version finds a MAC in this string:

mactool extract AA:18:FD:74:E1:A6:0B   
AA:18:FD:74:E1:A6

It should not find a MAC in this string since there is a :0B in the end: AA:18:FD:74:E1:A6:0B AA:18:FD:74:E1:A6

bitcanon commented 1 year ago

Try this: ((?<![:\-.\w])(?:[\da-fA-F]{2}[:\.-]){5}[\da-fA-F]{2}(?![:\-.\w]))

Test here: https://regex101.com/r/ekvkc1/1

bitcanon commented 1 year ago

This is a non-issue at the moment. Also seems quite impossible since Go doesn't support regex lookaheads.