In [36]:
# Tim Hatch -- thatch@google.com
# hands you regex?
# https://github.com/google/sre_yield
In [37]:
import sys
sys.path.append('/Users/thatch/code/sre_yield_thatch')
import sre_yield
reload(sre_yield)
Out[37]:
<module 'sre_yield' from '/Users/thatch/code/sre_yield_thatch/sre_yield.pyc'>
In [38]:
v = sre_yield.AllStrings('storage-(testing|current|next)|ad(spam)?')
In [39]:
len(v) # yep, it looks like a sequence
Out[39]:
5
In [40]:
list(v) # explicitly, for printing
Out[40]:
['storage-testing', 'storage-current', 'storage-next', 'ad', 'adspam']
In [41]:
'storage-testing' in v
Out[41]:
True
In [42]:
'storage-foo' in v
Out[42]:
False
In [43]:
# I actually found another use, for checking bigraphs for presidents!
# From http://xkcd.com/1313/
print ' '.join(sre_yield.AllStrings('bu|[rn]t|[coy]e|[mtg]a|j|iso|n[hl]|[ae]d|lev|sh|[lnd]i|[po]o|ls'))
bu rt nt ce oe ye ma ta ga j iso nh nl ad ed lev sh li ni di po oo ls

In [43]:
 
In [43]:
 
In [43]: