Skip to content

Instantly share code, notes, and snippets.

@odeke-em
Created December 28, 2015 03:24
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 odeke-em/c29ae8bc475fd0fb9eda to your computer and use it in GitHub Desktop.
Save odeke-em/c29ae8bc475fd0fb9eda to your computer and use it in GitHub Desktop.
drive-issue-535 contrast with other langs
#!/usr/bin/env python3
import re
reComp = re.compile('^\.(?!(mydotfile1|mydotfile2))$', re.UNICODE)
def main():
tests = ['.git', '.mydotfile', '.', '.mydotfile1', '.mydotfile2', 'other']
regexs = dict(provided=reComp)
for key, regex in regexs.items():
print("key \"%s\""%(key))
for test in tests:
print("query: \"%s\": "%(test), end="")
if regex.match(test):
print("\033[92mmatches\033[00m")
else:
print("\033[91mdoesn't match\033[00m")
print("**done**\n")
if __name__ == '__main__':
main()
$ chmod +x excludes.py && ./excludes.py 
key "provided"
query: ".git": doesn't match
query: ".mydotfile": doesn't match
query: ".": matches
query: ".mydotfile1": doesn't match
query: ".mydotfile2": doesn't match
query: "other": doesn't match
**done**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment