Skip to content

Instantly share code, notes, and snippets.

@lsferreira42
Last active January 8, 2019 17:56
Show Gist options
  • Save lsferreira42/a1a94d845c023ae0127ce1e83972bc70 to your computer and use it in GitHub Desktop.
Save lsferreira42/a1a94d845c023ae0127ce1e83972bc70 to your computer and use it in GitHub Desktop.
"""Extract jinja2 tags using regexps"""
import re
def extract_tags(value):
reg_findtag = "\{\{(.*?)\}\}"
p = re.compile(reg_findtag)
return p.findall(value)
a = "Ola {{nome}} qual o seu {{comida}} favorito?"
print(extract_tags(a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment