Skip to content

Instantly share code, notes, and snippets.

@dannyhvc
Last active October 29, 2021 05:46
Show Gist options
  • Save dannyhvc/810229371550b5a6b4ae5a6d453f4f4d to your computer and use it in GitHub Desktop.
Save dannyhvc/810229371550b5a6b4ae5a6d453f4f4d to your computer and use it in GitHub Desktop.
regex_index_filtering
pattern = re.compile(
r"(\[START\])|"
r"(\[PUSH\])|"
r"(\[ADD\])|"
r"(\[SUB\])|"
r"(\[[0-9]+(.)??[0-9]*\])|"
r"(\[POP\])|"
r"(\[FINISH\])")
spam = pattern.findall("[PUSH][1000][PUSH][3645][POP][FINISH]")
eggs = [next(filter(bool, local)) for local in spam]
print(eggs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment