Skip to content

Instantly share code, notes, and snippets.

@Ffisegydd
Created October 24, 2014 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ffisegydd/34d32e0f8a68b6756aaf to your computer and use it in GitHub Desktop.
Save Ffisegydd/34d32e0f8a68b6756aaf to your computer and use it in GitHub Desktop.
from itertools import permutations
import re
letters = 'abc'
perm = set(p for n in range(1, len(letters)+1) for p in permutations(letters, n))
s = r"@({})\b".format('|'.join(''.join(p) for p in perm))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment