Skip to content

Instantly share code, notes, and snippets.

@no1xsyzy
Created February 17, 2020 11: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 no1xsyzy/53d83a7c29ce4e5d94296b52836b12d7 to your computer and use it in GitHub Desktop.
Save no1xsyzy/53d83a7c29ce4e5d94296b52836b12d7 to your computer and use it in GitHub Desktop.
import re
PATTERN = r"/|(/[^.][^/]*|/[^/][^./][^/]*|/\.\.[^/]+)+/?"
assert re.fullmatch(PATTERN, "/abc/") is not None
assert re.fullmatch(PATTERN, "/abc/../") is None
assert re.fullmatch(PATTERN, "/abc/./") is None
assert re.fullmatch(PATTERN, "/abc/.123/") is not None
assert re.fullmatch(PATTERN, "/abc/a.123/") is not None
assert re.fullmatch(PATTERN, "/abc/a./") is not None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment