Skip to content

Instantly share code, notes, and snippets.

@briandailey
Created September 16, 2015 18:34
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 briandailey/a42bae857ed13e7a088e to your computer and use it in GitHub Desktop.
Save briandailey/a42bae857ed13e7a088e to your computer and use it in GitHub Desktop.
token parsing question.
"""
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