Skip to content

Instantly share code, notes, and snippets.

@treystout
Created January 23, 2013 19:58
Show Gist options
  • Save treystout/4612305 to your computer and use it in GitHub Desktop.
Save treystout/4612305 to your computer and use it in GitHub Desktop.
the actual regex is wrong (only matches first char), but it does load and compile
604 19:56:24 vagrant@trey-vagrant [~/real_outland] J:0 (outland_env) [back_to_sql] ⎆ cat regex.yaml
regex: '[a-z0-9\.-_]'
605 19:56:28 vagrant@trey-vagrant [~/real_outland] J:0 (outland_env) [back_to_sql] ⎆ bpython
>>> import re, yaml
>>> y = yaml.load(open('regex.yaml'))
>>> y
{'regex': '[a-z0-9\\.-_]'}
>>> r = re.compile(y['regex'])
>>> r.match('trey')
<_sre.SRE_Match object at 0x21a2d98>
>>> r.match('special$')
<_sre.SRE_Match object at 0x23a2578>
>>> r.match('#derp')
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment