$ 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**
Created
December 28, 2015 03:24
-
-
Save odeke-em/c29ae8bc475fd0fb9eda to your computer and use it in GitHub Desktop.
drive-issue-535 contrast with other langs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment