Skip to content

Instantly share code, notes, and snippets.

@DarkMio
Created January 7, 2016 11:35
Show Gist options
  • Save DarkMio/5d18859dd6abaaaa7377 to your computer and use it in GitHub Desktop.
Save DarkMio/5d18859dd6abaaaa7377 to your computer and use it in GitHub Desktop.
pattern_lines = """
f 1 2 3
f 1/2 3/4 5/6
f 1//2 3//4 5//6
f 1/2/3 4/5/6 7/8/9
"""
for pattern in pattern_lines.splitlines():
if pattern.beginsWith("f"):
line_begins_with_f(pattern)
def line_begins_with_f(pattern):
if pattern.matches("\/\/[\d\.]+\s"):
do_something(pattern)
continue
if pattern.matches("\/[\d\.]+\/"):
do_something_else(pattern)
continue
if pattern.matches("\/[\d\.]+"):
do_something_different(pattern)
continue
do_something_something(pattern)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment