Last active
October 29, 2021 05:46
-
-
Save dannyhvc/810229371550b5a6b4ae5a6d453f4f4d to your computer and use it in GitHub Desktop.
regex_index_filtering
This file contains 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
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