Date: Tue, 26 Aug 2008 22:12:19 -0500 From: Martin McCormick <martin@dc.cis.okstate.edu> To: freebsd-questions@freebsd.org Subject: Regular Expression Trouble Message-ID: <200808270312.m7R3CJNk076060@dc.cis.okstate.edu>
next in thread | raw e-mail | index | archive | help
I am trying to isolate only the MAC addresses that appear in dhcpd logs. For anyone who is interested, the sed construct that should do this looks like: sed 's/.*\([[ your regular expression ]]\).*/\1/' The \1 tells sed to only print what matched and skip all the rest. I am doing something wrong with the regular expression that is supposed to recognise a MAC address. MAC addresses look like 5 pairs of hex digits followed by :'s and then a 6TH pair to end the string. I have tried: [[:xdigit:][:xdigit:][:punct:] Sorry. It won't all fit on a line, but there should be a string of 5 pairs and the : and then the 6TH pair followed by the closing ] so the expression ends with ]] One should also be able to put: [[:xdigit:][:xdigit:][:punct:]]\{5,5\}[[:xdigit:][:xdigit]] Any ideas as to what else I can try? What happens is I get single characters per line that look like the first or maybe the last character in that line, but certainly nothing useful or nothing that remotely looks like a MAC address. Any ideas as to what's wrong with the regular expression? Many thanks. Martin McCormick WB5AGZ Stillwater, OK Systems Engineer OSU Information Technology Department Telecommunications Services Group
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808270312.m7R3CJNk076060>