I'm not sure why you're using so many |
operands. I stripped them out and used \s+
as delimiters and $
to match the end of string as a delimiter for the message but this works for me:
import re
text = r'2013-11-15 09:42:02 localhost dhcpd: DHCPACK on 10.51.1.242 to 00:1e:8c:21:83:a0 (Hostname Unsuitable for Printing) via eth2'
my_regexp = r'^(?P<date>[\d{2,4}-]*[\d{2}:\s]*)\s+(?P<host>\S+)\s+(?P<facility>\s*\S*):(\s+(?P<action>DHCP*\S*).+(?P<mac>([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]){2})\s+(?P<message>.*))*$'
print re.search( my_regexp, text).groupdict()
Output:
{'facility': 'dhcpd', 'host': 'localhost', 'date': '2013-11-15 09:42:02', 'mac': '00:1e:8c:21:83:a0', 'action': 'DHCPACK', 'message': '(Hostname Unsuitable for Printing) via eth2'}