Parsing Tex using python re library
Question: I want to parse the following part of a .tex file

    
    
    \section{a}
    some random lines with lot 
    of special characters
    \subsection{aa}
    somehthing here too
    \section{b}
    

I want the content within `\section{a}` and `\section{b}` inclusive so i tried
the following code in python

    
    
    import re
    a="my tex string mentioned above"
    b=re.findall(r'\\section{a}.*\\section{b}',a)
    print(b)
    

but i got `b=[]`. Where I am wrong?


Answer: You need to use the re.DOTALL flag to make the . match newlines, like this:

    
    
    b=re.findall(r'\\section{a}.*\\section{b}',a,re.DOTALL)
    

