I just finished to write the summary for calculus in Latex.

The main problem now is that the files contains many things I don't really need now.

The .tex files contains many definitions and theorems that i need to study by heart.

The definitions have their own definition in the tex file, so any definition in the file will start with:

```
\begin{definition}
```

and ends with

```
\end{definition}
```

And the same for theorems.

I need to write something to take out whatever is inside the `\begin{}...\end{}`

.

For example in a list called A:

```
\begin{document}
\begin{center}
\begin{definition} Hello WOrld! \end{definition}
\begin{example}A+B \end{example}
\begin{theorem} Tre Capre \end{theorem}
\begin{definition} Hello WOrld2! \end{definition}
\end{center}
\end{document}
```

should contains :`[[\begin{definition} Hello WOrld! \end{definition}],[\begin{theorem} Tre Capre \end{theorem}],[\begin{definition} Hello WOrld2! \end{definition}]]`

Looking in this site i found that i can use Regular Expressions:

```
for i in range(5):
x = i+1
raw = open('tex/chapter' + str(x) + '.tex')
A = []
for line in raw:
A.append(re.match(r'(\begin{definition})://.*\.(\end{definition})$', line))
print(A)
```

but the output is just `None`

and i don't really know why

Edit:

```
import re
for i in range(5):
x = i+1
raw = open('tex/chapter' + str(x) + '.tex')
A = re.findall(r'\\begin{definition}(.*?)\\end{definition}', raw.read())
print(A)
```

the output is the following:

```
[]
[]
[]
[]
[]
```