Created
September 16, 2015 18:34
-
-
Save briandailey/a42bae857ed13e7a088e to your computer and use it in GitHub Desktop.
token parsing question.
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
""" | |
for a string "{{ person }} wants to {{ verb }}" how can i return ['person', 'verb']? | |
""" | |
import re | |
string = "{{ person }} wants to {{ verb }}" | |
pattern = re.compile('{{ ([^ ]*) }}') | |
matches = re.findall(pattern, string) | |
# ['person', 'verb'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment