I have the following "sample" content:
{% block some_name %}Some Text{% endblock %}
Something Else
{% block another_name %}Some Other Content{% endblock %}
And I am trying to regex to find both blocks, first the names, then after that the sections, but am only receiving the first back from my "findall" action:
re.findall(r"\{% block ([^\{%]+?) %\}[\s\S]*\{% endblock %\}", contents)
** assuming variable "contents" is the string at the top.
So i need two searches, or combined if possible, returning me something alike:
list[
['some_name', 'another_name'],
['{% block some_name %}Some Text{% endblock %}', '{% block another_name %}Some Other Content{% endblock %}']
]
re.findall(r"(\{% block (.+?) %}[\s\S]*?\{% endblock %})", s)will do?