import re def grains(): match = re.match(r'^[a-zA-Z\-_]([0-1]+)([a-zA-Z]+)$', __grains__['host']) return { 'host_no': match.group(1), 'dc': match.group(2) }
Add a code snippet to your website: www.paste.org