Skip to content

Instantly share code, notes, and snippets.

@Alquimista
Created July 19, 2012 21:54
Show Gist options
  • Save Alquimista/3147115 to your computer and use it in GitHub Desktop.
Save Alquimista/3147115 to your computer and use it in GitHub Desktop.
import.re
post = """---
a:1
b: 2
---
asdf"""
RE_POST = re.compile("^---(?P<meta>.*)---(?P<html>.*)$", re.DOTALL)
RE_POST_MATCH = re.match(RE_POST, post)
print RE_POST_MATCH.group('meta').split('\n')
meta = {}
for m in RE_POST_MATCH.group('meta').split():
if m:
key, value = m.split()
meta[key] = value
print meta
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment